diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2019-12-12 15:27:09 -0700 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2019-12-12 15:27:09 -0700 |
commit | 5e9d81b507e0beb46b3812e21566bfef79c87af4 (patch) | |
tree | 86db08206e19897d13625765f94f870b714d92d7 /caddyconfig/httpcaddyfile | |
parent | 09a851706541317a36c7cc8ee58152a0a2fa3279 (diff) |
try_files, rewrite: allow query string in try_files (fix #2891)
Also some minor cleanup/improvements discovered along the way
Diffstat (limited to 'caddyconfig/httpcaddyfile')
-rw-r--r-- | caddyconfig/httpcaddyfile/directives.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/caddyconfig/httpcaddyfile/directives.go b/caddyconfig/httpcaddyfile/directives.go index 58aff98..5ec4993 100644 --- a/caddyconfig/httpcaddyfile/directives.go +++ b/caddyconfig/httpcaddyfile/directives.go @@ -53,6 +53,8 @@ func RegisterDirective(dir string, setupFunc UnmarshalFunc) { // RegisterHandlerDirective is like RegisterDirective, but for // directives which specifically output only an HTTP handler. +// Directives registered with this function will always have +// an optional matcher token as the first argument. func RegisterHandlerDirective(dir string, setupFunc UnmarshalHandlerFunc) { RegisterDirective(dir, func(h Helper) ([]ConfigValue, error) { if !h.Next() { @@ -117,7 +119,7 @@ func (h Helper) Caddyfiles() []string { } // JSON converts val into JSON. Any errors are added to warnings. -func (h Helper) JSON(val interface{}, warnings *[]caddyconfig.Warning) json.RawMessage { +func (h Helper) JSON(val interface{}) json.RawMessage { return caddyconfig.JSON(val, h.warnings) } @@ -135,9 +137,14 @@ func (h Helper) MatcherToken() (caddy.ModuleMap, bool, error) { // NewRoute returns config values relevant to creating a new HTTP route. func (h Helper) NewRoute(matcherSet caddy.ModuleMap, handler caddyhttp.MiddlewareHandler) []ConfigValue { - mod, err := caddy.GetModule(caddy.GetModuleName(handler)) + mod, err := caddy.GetModule(caddy.GetModuleID(handler)) if err != nil { - // TODO: append to warnings + *h.warnings = append(*h.warnings, caddyconfig.Warning{ + File: h.File(), + Line: h.Line(), + Message: err.Error(), + }) + return nil } var matcherSetsRaw []caddy.ModuleMap if matcherSet != nil { |