Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There are still some bugs about router #2900

Closed
rbee3u opened this issue Oct 12, 2021 · 2 comments
Closed

There are still some bugs about router #2900

rbee3u opened this issue Oct 12, 2021 · 2 comments
Labels

Comments

@rbee3u
Copy link

rbee3u commented Oct 12, 2021

The #2767 didn't solve the problem completely, here is how to reproduce:

package main

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

func main() {
	router := gin.Default()
	router.GET("/a/b", handler("/a/b"))
	router.GET("/a/:p/c", handler("/a/:p/c"))
	router.GET("/:p/d", handler("/:p/d"))
	_ = router.Run(":8080")
}

func handler(s string) gin.HandlerFunc {
	return func(c *gin.Context) {
		c.String(http.StatusOK, s)
	}
}

Expectations

$ curl 'http://127.0.0.1:8080/a/d'
/:p/d

Actual result

$ curl 'http://127.0.0.1:8080/a/d'
404 page not found

Suggestion

The backtracking progress need a stack for help, and it can't be solved by just caching the latest node.
So there are two ways:

  • /:p and /a can not appear at the same time, just like httprouter
  • we should use a stack data structure to help the backtracking
@appleboy
Copy link
Member

See the solution: #2897

@appleboy appleboy added the bug label Oct 15, 2021
@thinkerou
Copy link
Member

v1.7.7 have released, thanks! https://github.com/gin-gonic/gin/releases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants