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

Bug with mixed static and dynamic params #2894

Closed
ibraheemdev opened this issue Oct 7, 2021 · 1 comment
Closed

Bug with mixed static and dynamic params #2894

ibraheemdev opened this issue Oct 7, 2021 · 1 comment
Labels

Comments

@ibraheemdev
Copy link
Contributor

ibraheemdev commented Oct 7, 2021

Cross posted from #2767

package main

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

func main() {
	r := gin.Default()

	r.GET("/aa/:customer", newHandler("/aa/:customer"))
	r.GET("/aa/:customer/files/:file", newHandler("/aa/:customer/files/:file"))

	r.Run()
}

func newHandler(t string) func(c *gin.Context) {
	return func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": t,
		})
	}
}

For the above code example, the request results are:

/aa/1/files/aa  =>  /aa/:customer/files/:file
/aa/1/files/    =>  /aa/:customer
/aa/1/files     =>  404
/aa/1           =>  /aa/:customer
@appleboy
Copy link
Member

See solution #2897 already merged in the master branch.

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

2 participants