mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-19 07:43:17 +00:00
httpcaddyfile: Add optional status code argument to handle_errors
directive (#5965)
Co-authored-by: Aziz Rmadi <azizrmadi@Azizs-MacBook-Air.local>
This commit is contained in:
parent
5e2f1b5ced
commit
4181c79a81
8 changed files with 942 additions and 2 deletions
|
@ -774,10 +774,19 @@ func (st *ServerType) serversFromPairings(
|
|||
if srv.Errors == nil {
|
||||
srv.Errors = new(caddyhttp.HTTPErrorConfig)
|
||||
}
|
||||
sort.SliceStable(errorSubrouteVals, func(i, j int) bool {
|
||||
sri, srj := errorSubrouteVals[i].Value.(*caddyhttp.Subroute), errorSubrouteVals[j].Value.(*caddyhttp.Subroute)
|
||||
if len(sri.Routes[0].MatcherSetsRaw) == 0 && len(srj.Routes[0].MatcherSetsRaw) != 0 {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
})
|
||||
errorsSubroute := &caddyhttp.Subroute{}
|
||||
for _, val := range errorSubrouteVals {
|
||||
sr := val.Value.(*caddyhttp.Subroute)
|
||||
srv.Errors.Routes = appendSubrouteToRouteList(srv.Errors.Routes, sr, matcherSetsEnc, p, warnings)
|
||||
errorsSubroute.Routes = append(errorsSubroute.Routes, sr.Routes...)
|
||||
}
|
||||
srv.Errors.Routes = appendSubrouteToRouteList(srv.Errors.Routes, errorsSubroute, matcherSetsEnc, p, warnings)
|
||||
}
|
||||
|
||||
// add log associations
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue