Browse Source
reverse_proxy: Add flush_interval to caddyfile syntax (#1460)
Also add godoc for Caddyfile syntax for file_server
master
Matthew Holt
6 years ago
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5
2 changed files with
23 additions and
0 deletions
-
modules/caddyhttp/fileserver/caddyfile.go
-
modules/caddyhttp/reverseproxy/caddyfile.go
|
|
@ -27,6 +27,16 @@ func init() { |
|
|
|
httpcaddyfile.RegisterDirective("try_files", parseTryFiles) |
|
|
|
} |
|
|
|
|
|
|
|
// parseCaddyfile parses the file_server directive. It enables the static file
|
|
|
|
// server and configures it with this syntax:
|
|
|
|
//
|
|
|
|
// file_server [<matcher>] [browse] {
|
|
|
|
// root <path>
|
|
|
|
// hide <files...>
|
|
|
|
// index <files...>
|
|
|
|
// browse [<template_file>]
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) { |
|
|
|
var fsrv FileServer |
|
|
|
|
|
|
|
|
|
@ -68,6 +68,9 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) |
|
|
|
// unhealthy_status <status>
|
|
|
|
// unhealthy_latency <duration>
|
|
|
|
//
|
|
|
|
// # streaming
|
|
|
|
// flush_interval <duration>
|
|
|
|
//
|
|
|
|
// # header manipulation
|
|
|
|
// header_up [+|-]<field> [<value|regexp> [<replacement>]]
|
|
|
|
// header_down [+|-]<field> [<value|regexp> [<replacement>]]
|
|
|
@ -328,6 +331,16 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { |
|
|
|
} |
|
|
|
h.HealthChecks.Passive.UnhealthyLatency = caddy.Duration(dur) |
|
|
|
|
|
|
|
case "flush_interval": |
|
|
|
if !d.NextArg() { |
|
|
|
return d.ArgErr() |
|
|
|
} |
|
|
|
dur, err := time.ParseDuration(d.Val()) |
|
|
|
if err != nil { |
|
|
|
return d.Errf("bad duration value '%s': %v", d.Val(), err) |
|
|
|
} |
|
|
|
h.FlushInterval = caddy.Duration(dur) |
|
|
|
|
|
|
|
case "header_up": |
|
|
|
if h.Headers == nil { |
|
|
|
h.Headers = new(headers.Handler) |
|
|
|