Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
reverse_proxy: Add flush_interval to caddyfile syntax (#1460)
Also add godoc for Caddyfile syntax for file_server
Matthew Holt committed
Nov 27, 2019 at 11:51 UTC
db4293cb5fce33b467b50ef77698f69a4a066215
2 files changed
+23
modules/caddyhttp/fileserver/caddyfile.go
+10
@@ -27,6 +27,16 @@ func init() {
27
httpcaddyfile.RegisterDirective("try_files", parseTryFiles)
28
}
29
30
+// parseCaddyfile parses the file_server directive. It enables the static file
31
+// server and configures it with this syntax:
32
+//
33
+// file_server [<matcher>] [browse] {
34
+// root <path>
35
+// hide <files...>
36
+// index <files...>
37
+// browse [<template_file>]
38
+// }
39
+//
40
func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) {
41
var fsrv FileServer
42
modules/caddyhttp/reverseproxy/caddyfile.go
+13
@@ -68,6 +68,9 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error)
68
// unhealthy_status <status>
69
// unhealthy_latency <duration>
70
//
71
+// # streaming
72
+// flush_interval <duration>
73
+//
74
// # header manipulation
75
// header_up [+|-]<field> [<value|regexp> [<replacement>]]
76
// header_down [+|-]<field> [<value|regexp> [<replacement>]]
@@ -328,6 +331,16 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
331
}
332
h.HealthChecks.Passive.UnhealthyLatency = caddy.Duration(dur)
333
334
+ case "flush_interval":
335
+ if !d.NextArg() {
336
+ return d.ArgErr()
337
+ }
338
+ dur, err := time.ParseDuration(d.Val())
339
+ if err != nil {
340
+ return d.Errf("bad duration value '%s': %v", d.Val(), err)
341
+ }
342
+ h.FlushInterval = caddy.Duration(dur)
343
+
344
case "header_up":
345
if h.Headers == nil {
346
h.Headers = new(headers.Handler)