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

docs(context): #3369 modify the annotation about Context.Param() #3414

Merged
merged 1 commit into from
Dec 1, 2022
Merged

docs(context): #3369 modify the annotation about Context.Param() #3414

merged 1 commit into from
Dec 1, 2022

Conversation

Cookiery
Copy link
Contributor

If you don't want to motify the annotation. Maybe I can fix it in the tree.go (func Get or func ByName).

Please feel free to reach out with any questions.

Thank you very much.

@appleboy appleboy changed the title #3369 modify the annotation about Context.Param() docs(context): #3369 modify the annotation about Context.Param() Dec 1, 2022
@appleboy appleboy merged commit cc367f9 into gin-gonic:master Dec 1, 2022
@ccf5maj37
Copy link

This change is wrong in v1.9.1.
The return of c.Param doesn't contain slash.

@AnshulKanwar
Copy link

Any update on this @Cookiery? I am on v1.9.1 and c.Param doesn't contain a slash

router.GET("/user/:id", func(c *gin.Context) {
    // a GET request to /user/john
    id := c.Param("id") // id == "john"
    // a GET request to /user/john/
    id := c.Param("id") // id == "john"
})

@Cookiery
Copy link
Contributor Author

Cookiery commented Oct 4, 2024

Comment was updated

// Param returns the value of the URL param.
// It is a shortcut for c.Params.ByName(key)
//
//	router.GET("/user/:id", func(c *gin.Context) {
//	    // a GET request to /user/john
//	    id := c.Param("id") // id == "john"
//	    // a GET request to /user/john/
//	    id := c.Param("id") // id == "/john/"
//	})

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

Successfully merging this pull request may close these issues.

4 participants