Simple Web ServerSimple Web Server
下载
文档
  • English
  • 简体中文
  • 繁體中文
  • Español
  • Français
  • Português
  • Русский
  • Deutsch
  • 日本
  • 한국어
  • Italiano
  • Українська
  • Azərbaycanca
  • Nederlands
  • Svenska
GitHub
下载
文档
  • English
  • 简体中文
  • 繁體中文
  • Español
  • Français
  • Português
  • Русский
  • Deutsch
  • 日本
  • 한국어
  • Italiano
  • Українська
  • Azərbaycanca
  • Nederlands
  • Svenska
GitHub
    • 服务器配置
    • 应用设置
    • 编辑 config.json
    • 使用 HTTPS
    • 查看日志
    • 从源码构建
    • 来自Chrome的Web Server?
    • 插件介绍
    • 插件清单文件
    • 插件脚本
    • 使用.swshtaccess文件进行高级配置
    • 使用自定义脚本
    • 创建自定义httpRequest程序

插件脚本

此页未完成。 See issue #119

Make sure to cover:

How to access plugin options (and mention that all options are optional and not validated at all. Types might not necessarily match what is specified in the manifest, and options could be undefined. No guarantees.)

How to access server options

Both onStart and onRequest are optional

hat you can do with server, and examples of modifying it

How to throw errors

How preventDefault works

What you can do with res and req, and common examples such as getting the request path, setting headers, getting cookies, and editing page content

Add a few example scripts for common use cases:

  • Adding a custom header
  • Creating a 301/302 redirect from one directory to another, preserving query parameters
  • Creating a rewrite from one directory to another
  • Modifying the contents of the returned file if it's an html file, such as injecting a script tag, or replacing Copyright [YEAR] with the current year
  • Requiring http authentication for only a specific directory or file

How to include/require other files.

Edit this page on GitHub
Prev
插件清单文件