Open blaubaer opened 7 years ago
Will be mostly irrelevant in Caddy 2, which provides this capability through other means.
Any updates on this one?
@yesiyan01 what exactly are you looking for? Could you be more specific? What you want is probably possible another way.
@francislavoie
I have a reverse proxy handler that overrides authorization header e.g.
handler: reverse_proxy
headers:
request:
set:
Authorization:
- '{http.oauth1}'
transport:
protocol: http
tls: {}
upstreams:
- dial: 'xxx.com:443'
where 'http.oauth1' is a custom header value set from a custom module.
I'd like the ability to use 'http.oauth1' in the placeholder but fallback to a static API-KEY when http.oauth1 is not present.
Thanks for the example!
The changes would need to be made to https://github.com/caddyserver/caddy/blob/master/replacer.go, if you'd like to take a crack at it.
We recently implemented defaults for environment variables in the Caddyfile, so I think we should follow suit in this case and use the same syntax, i.e. :
as the delimiter for the default value.
This change would need to be thoroughly tested (see replacer_test.go
)
If there is no/empty for a placeholder use default/fallback value/placeholder.
Acceptance Test
Pattern
Expectations
foo
bar
John
Mark
John
John
John
Mark
Mark
Usage example
Other software which uses this pattern
https://logback.qos.ch/manual/configuration.html#defaultValuesForVariables