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

✨ Add method to get an integer directly from the Ctx params (route params) #1243

Merged
merged 5 commits into from
Mar 28, 2021

Conversation

eacp
Copy link
Contributor

@eacp eacp commented Mar 26, 2021

Please provide enough information so that others can review your pull request:

I added a method to Ctx and its tests. The method is ParamsInt. It helps developers get an integer directly from the request

Explain the details for making this change. What existing problem does the pull request solve?

It is very common to send integers like IDs directly in the route as parameters. I added an utility function, ParamsInt to directly get an integer from the Ctx that is passed on each request. It returns zero and an error if the param cannot be found OR if the param is not a valid integer

Commit formatting

Use emojis on commit messages so it provides an easy way of identifying the purpose or intention of a commit. Check out the emoji cheatsheet here: https://gitmoji.carloscuesta.me/

@welcome
Copy link

welcome bot commented Mar 26, 2021

Thanks for opening this pull request! 🎉 Please check out our contributing guidelines. If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@eacp eacp changed the title ✨ Add method to get an integer directly from the Ctx params (route params) ✨ Add method to get an integer directly from the Ctx params (route params) Mar 26, 2021
@ReneWerner87
Copy link
Member

Thx for the contribution and effort

Could you add an pull request here
https://github.com/gofiber/docs/pulls

@ReneWerner87 ReneWerner87 self-requested a review March 28, 2021 13:48
@ReneWerner87 ReneWerner87 merged commit 47f44f3 into gofiber:master Mar 28, 2021
@welcome
Copy link

welcome bot commented Mar 28, 2021

Congrats on merging your first pull request! 🎉 We here at Fiber are proud of you! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@ReneWerner87
Copy link
Member

thanks for the implementation,

we have internally consulted a bit and merge the pull request, but it may be that we still make optimizations and add another method for floats.

@ReneWerner87
Copy link
Member

@eacp
Please don´t forget to add it to our documentation repository
https://github.com/gofiber/docs

eacp added a commit to eacp/docs that referenced this pull request Apr 1, 2021
Added documentation for as requested by [this comment](gofiber/fiber#1243 (comment))
@eacp
Copy link
Contributor Author

eacp commented Apr 1, 2021

@ReneWerner87 I have added the documentation in this pr

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

Successfully merging this pull request may close these issues.

None yet

2 participants