fix: in fixpath case, wildcard node should be the last child.
define {prefix}/{param path like :id} and {prefix}/, and than access no defined path like {prefix}/... will panic for panic("invalid node type").
for it didn't obtain the wildcard child node correctly.
here is a example case. after start server, access http://localhost:8080/prefix/a/b/c , will cause panic.
package main
import (
"errors"
"net/http"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
r.RedirectFixedPath = true
r.GET("/prefix/:id", func(c *gin.Context) {
c.JSON(200, "id")
})
r.GET("/prefix/xxx", func(c *gin.Context) {
c.JSON(200, "xxx")
})
if err := r.Run(":8080"); err != nil && errors.Is(err, http.ErrServerClosed) {
panic(err)
}
}
Please add unit testing for the cause.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 98.81%. Comparing base (3dc1cd6) to head (deb81c1).
:warning: Report is 194 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #4394 +/- ##
==========================================
- Coverage 99.21% 98.81% -0.40%
==========================================
Files 42 44 +2
Lines 3182 3467 +285
==========================================
+ Hits 3157 3426 +269
- Misses 17 30 +13
- Partials 8 11 +3
| Flag | Coverage Δ | |
|---|---|---|
? |
||
| --ldflags="-checklinkname=0" -tags sonic | 98.80% <100.00%> (?) |
|
| -tags go_json | 98.75% <100.00%> (?) |
|
| -tags nomsgpack | 98.80% <100.00%> (?) |
|
| go-1.18 | ? |
|
| go-1.19 | ? |
|
| go-1.20 | ? |
|
| go-1.21 | ? |
|
| go-1.24 | 98.81% <100.00%> (?) |
|
| go-1.25 | 98.81% <100.00%> (?) |
|
| macos-latest | 98.81% <100.00%> (-0.40%) |
:arrow_down: |
| ubuntu-latest | 98.81% <100.00%> (-0.40%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Please add unit testing for the cause.
Sorry, I thought such a small point didn't need to add tests. I added a test situation on the basis of the original test function. This test situation will cause panic before the error is fixed.