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
parent
commit
db4293cb5f
No known key found for this signature in database GPG Key ID: 2A349DD577D586A5
  1. 10
      modules/caddyhttp/fileserver/caddyfile.go
  2. 13
      modules/caddyhttp/reverseproxy/caddyfile.go

10
modules/caddyhttp/fileserver/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

13
modules/caddyhttp/reverseproxy/caddyfile.go

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

Loading…
Cancel
Save