reverse_proxy: Add flush_interval to caddyfile syntax (#1460)

Also add godoc for Caddyfile syntax for file_server
This commit is contained in:
Matthew Holt 2019-11-27 11:51:32 -07:00
parent 6e10586303
commit db4293cb5f
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5
2 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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)