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

🚀 Default value from QueryParser #1306

Closed
fsanano opened this issue Apr 30, 2021 · 3 comments
Closed

🚀 Default value from QueryParser #1306

fsanano opened this issue Apr 30, 2021 · 3 comments

Comments

@fsanano
Copy link

fsanano commented Apr 30, 2021

Does it possible to use the default tag in the struct to pass default value of query parameter?

type Request struct {
	Limit int `query:"limit" default:"10"`
}
var request Request
ctx.QueryParser(&request);
limit := request.Limit // 10

@welcome
Copy link

welcome bot commented Apr 30, 2021

Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@hi019
Copy link
Contributor

hi019 commented May 4, 2021

No, this is not built in to Fiber. Try this https://github.com/mcuadros/go-defaults

@hi019 hi019 closed this as completed May 4, 2021
@gopkg-dev
Copy link
Contributor

I think this feature is necessary to add. Can it be considered?

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

No branches or pull requests

4 participants