File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 4
4
5
5
> Author : Alan Chen
6
6
7
- > version: 0.0.9
7
+ > version: 0.1.0
8
8
9
9
> node >= 8.11.1
10
10
11
- > Date: 2019/4/25
11
+ > Date: 2019/12/4
12
12
13
13
<div align =" center " >
14
14
74
74
导出一个类,自带1个静态方法` start ` 。返回一个promise,then表示当前路径是否存在静态文件,会返回文件,reject表示当前路径不存在静态文件,会返回一个Error对象。参数如下:
75
75
* IncomingMessage ` [可读流] ` ,Http Server类request事件的第一个参数req
76
76
* ServerResponse ` [可写流] ` ,Http Server类request事件的第二个参数res
77
- * opts ` [Object] ` , 目前支持两个key。
77
+ * opts ` [Object] ` , 目前支持:
78
78
* rootPath ` [String] ` 指定文件目录作为服务器根目录,默认为'/',即进程运行的的目录
79
79
* homePage ` [String] ` 当req的url为'/'时跳转的首页文件,默认为'index.html'
80
+ * returnContentType ` [Boolean] ` 是否返回请求对应文件的content-type响应头,默认为true
81
+ * gzip ` [Boolean] ` 是否对静态文件gzip压缩,默认为false
82
+ * gzipExclude ` [Array<string>] ` 忽略gzip压缩的文件后缀名list,默认为[ ]
83
+
84
+ > 如果开启了gzip,并且目录里存在原文件和被gzip压缩的文件,则插件不会再次压缩,会直接读取gz文件。这样避免了静态服务器的性能开销。但必须保证原文件存在,例如:` index.html ` 和` index.html.gz ` 。
80
85
81
86
> 基于两个插件实现的express中间件` proxyMiddleware ` 和` staticMiddleware ` 用法同上面类似,可以去[ example/express] ( ./example/express/index.js ) 看详细例子。
82
87
You can’t perform that action at this time.
0 commit comments