Skip to content

Commit

Permalink
fix(caddy): surrogate-related config parsing (#449)
Browse files Browse the repository at this point in the history
Co-authored-by: Vincent Jordan <vincent.jordan@platform.sh>
  • Loading branch information
vejipe and Vincent Jordan committed Feb 7, 2024
1 parent 583080e commit 3acd7f2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugins/caddy/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func parseRedisConfiguration(c map[string]interface{}) map[string]interface{} {
return c
}

func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking bool) error {
func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isGlobal bool) error {
for h.Next() {
for nesting := h.Nesting(); h.NextBlock(nesting); {
rootOption := h.Val()
Expand All @@ -280,6 +280,9 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
allowed = append(allowed, h.RemainingArgs()...)
cfg.DefaultCache.AllowedHTTPVerbs = allowed
case "api":
if !isGlobal {
return h.Err("'api' block must be global")
}
apiConfiguration := configurationtypes.API{}
for nesting := h.Nesting(); h.NextBlock(nesting); {
directive := h.Val()
Expand Down Expand Up @@ -388,8 +391,10 @@ func parseConfiguration(cfg *Configuration, h *caddyfile.Dispenser, isBlocking b
case "api_key":
cdn.APIKey = h.RemainingArgs()[0]
case "dynamic":
if len(h.RemainingArgs()) > 0 {
cdn.Dynamic, _ = strconv.ParseBool(h.RemainingArgs()[0])
cdn.Dynamic = true
args := h.RemainingArgs()
if len(args) > 0 {
cdn.Dynamic, _ = strconv.ParseBool(args[0])
}
case "hostname":
cdn.Hostname = h.RemainingArgs()[0]
Expand Down

0 comments on commit 3acd7f2

Please sign in to comment.