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

Wrong matched route path in the context #1917

Closed
drsect0r opened this issue May 28, 2019 · 6 comments
Closed

Wrong matched route path in the context #1917

drsect0r opened this issue May 28, 2019 · 6 comments
Labels
Milestone

Comments

@drsect0r
Copy link

  • go version go1.12 linux/amd64
  • gin commit 6e320c9
  • Ubuntu inside Windows Subsystem for Linux

Description

We were pretty excited to perform code cleanup after #1826 was merged into master. We removed the git checkout and the #1390 patch present in our CI pipeline and worked based upon the latest master.

We noticed that one endpoint stopped working as expected and discovered that it was being misreported as a different route. As a test, we removed the erroneous route, but the endpoint in question still reported a wrong route path.

For now, we have restored the #1390 patch on top of commit e526148 and this resolved the issue.

@thinkerou
Copy link
Member

@drsect0r can you post mini example in order to reproduce the issue? thanks!

@thinkerou thinkerou added the bug label Jun 7, 2019
@thinkerou thinkerou added this to the 1.5 milestone Jun 7, 2019
@caihangui
Copy link

caihangui commented Jun 14, 2019

I think I had met the same problem @thinkerou

this is my code

func main() {
	r := gin.Default()
	r.GET("/ping", func(c *gin.Context) {

		fmt.Println("ping function 's c.FullPath() == ",c.FullPath())

		fmt.Println("c.FullPath() == \"/ping\" : ",c.FullPath() == "/ping")

		c.JSON(http.StatusOK, gin.H{})
	})

	r.GET("/pong", func(c *gin.Context) {

		fmt.Println("pong function 's c.FullPath() == ",c.FullPath())

		fmt.Println("c.FullPath() == \"/pong\" : ",c.FullPath() == "/pong")

		c.JSON(http.StatusOK, gin.H{})
	})

	r.Run()
}

but its result don't be expected

pong function 's c.FullPath() ==  /pong
c.FullPath() == "/pong" :  true
[GIN] 2019/06/14 - 14:52:58 | 200 |     199.792µs |             ::1 | GET      /pong
ping function 's c.FullPath() ==  /pong
c.FullPath() == "/ping" :  false
[GIN] 2019/06/14 - 14:53:07 | 200 |      42.793µs |             ::1 | GET      /ping

@bbiao
Copy link
Contributor

bbiao commented Jun 14, 2019

My PR can fix your problems

=============
@caihangui the output will be like below if you apply my patch

ping function 's c.FullPath() == /ping
c.FullPath() == "/ping" : true
[GIN] 2019/06/14 - 15:23:21 | 200 | 95.29µs | 127.0.0.1 | GET /ping
pong function 's c.FullPath() == /pong
c.FullPath() == "/pong" : true
[GIN] 2019/06/14 - 15:23:27 | 200 | 44.114µs | 127.0.0.1 | GET /pong

#1919

@bbiao
Copy link
Contributor

bbiao commented Jun 14, 2019

@drsect0r you can try this patch #1919

@drsect0r
Copy link
Author

drsect0r commented Jun 16, 2019

@bbiao Thank you for your patch! Will apply it tomorrow and report back.

Edit: Patch resolves the problem for us.

@thinkerou
Copy link
Member

merged!

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

4 participants