gin icon indicating copy to clipboard operation
gin copied to clipboard

Feat: allow "/*catch-all" and "/normal" routes coexist

Open StephanoGeorge opened this issue 1 year ago • 2 comments

Allow /*catch-all and /normal routes coexist, like /*filepath, /users/me, /users/*user.

/users will match /users/*user, and the param will be [{"user": "/"}], unless route /users/ added.

Param and catch-all parts are still in conflict: /*filepath, /:action, but this is quite reasonable, after all, wo can't say that a path with only one slash should correspond to param.

Reason for removing empty node before /*catch-all node:

  • Now empty node can't guarantee that path must start with a slash when entering catch-all.
  • n.wildChild will be false when n has a catch-all empty node as child, so we have to check n.children[len(n.children)-1].wildChild, there was no problem before because there would be no coexistence of /normal routes and /*catch-all routes before.

fixes #2102 fixes #2846 fixes #2920 fixes #2930

StephanoGeorge avatar Aug 06 '22 15:08 StephanoGeorge

Codecov Report

Merging #3270 (8f2fd7a) into master (ad66d9d) will decrease coverage by 0.26%. The diff coverage is 99.42%.

:exclamation: Current head 8f2fd7a differs from pull request most recent head 90a6a2c. Consider uploading reports for the commit 90a6a2c to get more accurate results

@@            Coverage Diff             @@
##           master    #3270      +/-   ##
==========================================
- Coverage   98.36%   98.10%   -0.27%     
==========================================
  Files          42       42              
  Lines        3124     3107      -17     
==========================================
- Hits         3073     3048      -25     
- Misses         38       45       +7     
- Partials       13       14       +1     
Flag Coverage Δ
98.10% <99.42%> (-0.27%) :arrow_down:
go-1.15 98.10% <99.42%> (-0.27%) :arrow_down:
go-1.16 ∅ <ø> (?)
go-1.17 98.00% <99.42%> (-0.27%) :arrow_down:
go-1.18 98.00% <99.42%> (-0.27%) :arrow_down:
macos-latest 98.10% <99.42%> (-0.27%) :arrow_down:
ubuntu-latest 98.10% <99.42%> (-0.27%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
tree.go 98.57% <99.42%> (-1.43%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Aug 07 '22 15:08 codecov[bot]

Please approval workflows. I force pushed because I fixed code coverage, and squashed commits down to just 2.

StephanoGeorge avatar Aug 09 '22 12:08 StephanoGeorge

Is there any progress on this feature? We need this feature.

aix3 avatar Aug 15 '23 04:08 aix3