mirror of
https://github.com/caddyserver/caddy.git
synced 2026-05-30 18:45:18 -04:00
reverseproxy: Implement health_uri, deprecate health_path, supports query (#4050)
* reverseproxy: Implement health_uri, replaces health_path, supports query Also fixes a bug with `health_status` Caddyfile parsing , it would always only take the first character of the status code even if it didn't end with "xx". * reverseproxy: Rename to URI, named logger, warn in Provision (for JSON)
This commit is contained in:
@@ -288,6 +288,18 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
||||
}
|
||||
h.LoadBalancing.TryInterval = caddy.Duration(dur)
|
||||
|
||||
case "health_uri":
|
||||
if !d.NextArg() {
|
||||
return d.ArgErr()
|
||||
}
|
||||
if h.HealthChecks == nil {
|
||||
h.HealthChecks = new(HealthChecks)
|
||||
}
|
||||
if h.HealthChecks.Active == nil {
|
||||
h.HealthChecks.Active = new(ActiveHealthChecks)
|
||||
}
|
||||
h.HealthChecks.Active.URI = d.Val()
|
||||
|
||||
case "health_path":
|
||||
if !d.NextArg() {
|
||||
return d.ArgErr()
|
||||
@@ -299,6 +311,7 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
||||
h.HealthChecks.Active = new(ActiveHealthChecks)
|
||||
}
|
||||
h.HealthChecks.Active.Path = d.Val()
|
||||
caddy.Log().Named("config.adapter.caddyfile").Warn("the 'health_path' subdirective is deprecated, please use 'health_uri' instead!")
|
||||
|
||||
case "health_port":
|
||||
if !d.NextArg() {
|
||||
@@ -382,7 +395,7 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
||||
if len(val) == 3 && strings.HasSuffix(val, "xx") {
|
||||
val = val[:1]
|
||||
}
|
||||
statusNum, err := strconv.Atoi(val[:1])
|
||||
statusNum, err := strconv.Atoi(val)
|
||||
if err != nil {
|
||||
return d.Errf("bad status value '%s': %v", d.Val(), err)
|
||||
}
|
||||
@@ -463,7 +476,7 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
||||
if len(arg) == 3 && strings.HasSuffix(arg, "xx") {
|
||||
arg = arg[:1]
|
||||
}
|
||||
statusNum, err := strconv.Atoi(arg[:1])
|
||||
statusNum, err := strconv.Atoi(arg)
|
||||
if err != nil {
|
||||
return d.Errf("bad status value '%s': %v", d.Val(), err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user