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

How to control behavior for missing URL params? (1.3.0 - 1.4.0 change) #2199

Open
pmalekn opened this issue Dec 30, 2019 · 0 comments
Open

Comments

@pmalekn
Copy link

pmalekn commented Dec 30, 2019

Description

I'm working on migrating from 1.3.0 to 1.4.0 (or 1.5.0) and I've discovered that 1.3.0 for the following snippet

router := gin.New()
router.GET("/func/:id/details", func(c *gin.Context) {
    value := c.Param("id")
    fmt.Printf("value is %v\n", value)
})

Would always get to the handler even when requesting /func//details (note the missing URL param) whereas 1.4.0 and above will return 404.

Is it possible to control this behavior? (to work the same way as it worked in 1.3.0?)

How to reproduce

Start below router

router := gin.New()
router.GET("/func/:id/details", func(c *gin.Context) {
    value := c.Param("id")
    fmt.Printf("value is %v\n", value)
})
router.Run("localhost:8080")

And make the following request with curl

curl -i localhost:8080/func//details

Expectations

HTTP 200 (get inside the handler)

Actual result

HTTP 404

Environment

  • go version: 1.13.5
  • gin version (or commit ref): 1.3.0
  • operating system: Mac os 10.15.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant