httpcaddyfile: Fix sorting edgecase for nested handle_path
#4477
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes a bug reported in https://caddy.community/t/handle-path-being-ignored-when-paired-with-handle-in-same-block/14393
We had some code in
ServerType.Setup()that would ensurehandle_pathhas the same sort level ashandle, but we were missing the same check inparseSegmentAsConfigto make sure that works properly inside of any nested subroute (handle,route,handle_errors,handle_response).To be clear, the fix is copy-paste from another spot where we do the same thing:
caddy/caddyconfig/httpcaddyfile/httptype.go
Lines 196 to 202 in 78b5356
The new test fails before the change (the
handle_pathends up after thehandlein the same level, and they're missing agroupname because the group is omitted if there's no two handlers with the same level) and passes after.