mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 06:03:48 +03:00
fileserver: Add disable_canonical_uris
Caddyfile subdirective (#4222)
* feat(fileserver): add 'canonical_uris' parameter to caddyfile add 'canonical_uris' parameter to caddyfile reference #2741 Signed-off-by: mritd <mritd@linux.com> * feat(file_server): rename subdirective canonical_uris to disable_canonical_uris rename subdirective canonical_uris to disable_canonical_uris Signed-off-by: mritd <mritd@linux.com> * test(caddyfile_adapt): add disable_canonical_uris subdirective test file add disable_canonical_uris subdirective test file Signed-off-by: mritd <mritd@linux.com>
This commit is contained in:
parent
0bdb8aa82d
commit
4245ceb67d
2 changed files with 40 additions and 0 deletions
|
@ -0,0 +1,32 @@
|
||||||
|
:80
|
||||||
|
|
||||||
|
file_server {
|
||||||
|
disable_canonical_uris
|
||||||
|
}
|
||||||
|
----------
|
||||||
|
{
|
||||||
|
"apps": {
|
||||||
|
"http": {
|
||||||
|
"servers": {
|
||||||
|
"srv0": {
|
||||||
|
"listen": [
|
||||||
|
":80"
|
||||||
|
],
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"handle": [
|
||||||
|
{
|
||||||
|
"canonical_uris": false,
|
||||||
|
"handler": "file_server",
|
||||||
|
"hide": [
|
||||||
|
"./Caddyfile"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -41,6 +41,7 @@ func init() {
|
||||||
// browse [<template_file>]
|
// browse [<template_file>]
|
||||||
// precompressed <formats...>
|
// precompressed <formats...>
|
||||||
// status <status>
|
// status <status>
|
||||||
|
// disable_canonical_uris
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) {
|
func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) {
|
||||||
|
@ -112,6 +113,13 @@ func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error)
|
||||||
}
|
}
|
||||||
fsrv.StatusCode = caddyhttp.WeakString(h.Val())
|
fsrv.StatusCode = caddyhttp.WeakString(h.Val())
|
||||||
|
|
||||||
|
case "disable_canonical_uris":
|
||||||
|
if h.NextArg() {
|
||||||
|
return nil, h.ArgErr()
|
||||||
|
}
|
||||||
|
falseBool := false
|
||||||
|
fsrv.CanonicalURIs = &falseBool
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nil, h.Errf("unknown subdirective '%s'", h.Val())
|
return nil, h.Errf("unknown subdirective '%s'", h.Val())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue