mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-16 21:56:40 -05:00
headers: Fix Caddyfile parsing with request matcher (#3892)
This commit is contained in:
parent
4afcdc49d1
commit
a26f70a12b
2 changed files with 29 additions and 0 deletions
|
@ -9,6 +9,10 @@
|
||||||
?Tim "Berners-Lee"
|
?Tim "Berners-Lee"
|
||||||
defer
|
defer
|
||||||
}
|
}
|
||||||
|
@images path /images/*
|
||||||
|
header @images {
|
||||||
|
Cache-Control "public, max-age=3600, stale-while-revalidate=86400"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
----------
|
----------
|
||||||
{
|
{
|
||||||
|
@ -20,6 +24,27 @@
|
||||||
":80"
|
":80"
|
||||||
],
|
],
|
||||||
"routes": [
|
"routes": [
|
||||||
|
{
|
||||||
|
"match": [
|
||||||
|
{
|
||||||
|
"path": [
|
||||||
|
"/images/*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"handle": [
|
||||||
|
{
|
||||||
|
"handler": "headers",
|
||||||
|
"response": {
|
||||||
|
"set": {
|
||||||
|
"Cache-Control": [
|
||||||
|
"public, max-age=3600, stale-while-revalidate=86400"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"handle": [
|
"handle": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,6 +46,10 @@ func init() {
|
||||||
// and ? conditionally sets a value only if the header field is not already
|
// and ? conditionally sets a value only if the header field is not already
|
||||||
// set.
|
// set.
|
||||||
func parseCaddyfile(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) {
|
func parseCaddyfile(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error) {
|
||||||
|
if !h.Next() {
|
||||||
|
return nil, h.ArgErr()
|
||||||
|
}
|
||||||
|
|
||||||
matcherSet, err := h.ExtractMatcherSet()
|
matcherSet, err := h.ExtractMatcherSet()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue