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

In Get method, for getting params, use context::FormValues or context::URLParams? #1168

Closed
zheeeng opened this issue Jan 7, 2019 · 3 comments

Comments

@zheeeng
Copy link

zheeeng commented Jan 7, 2019

In most cases, they are equivalent. But for some API contains params array, for example:

https://api.example.com/books?id=123&id=3435

pick id from context::FormValues, we get []string{"123", "3435"},
pick id from context::URLParams, we get "123,3435"

Should we always use context::FormValues to get params instead of using context::URLParams for all cases?

@kataras
Copy link
Owner

kataras commented Jan 7, 2019

URLParams gives a map[string]string, FormValues gives a string slice as you correctly pointed out, we can't change how these two are working( we don't want to introduce such a breaking change) but we can document the changes of these two better if you think that will help users, although I recommend use of FormValues for values that will going to be saved somewhere or used for authentication and etc. and use of URLParams to get things like ?referer= or ?id= which should be only one value per key. Tell me what are you thinking and we can make it happen.

Irrelevant, but, did you check my response on #1165 (comment) ?

@zheeeng
Copy link
Author

zheeeng commented Jan 7, 2019

I agree to document these suggestions.

I'm refactoring some codes with your example in #1165 (comment), and will post the progress soon at that issue.

@kataras
Copy link
Owner

kataras commented Jan 7, 2019

You know why I didn't document these basics things? because net/http works the same way for form values and url params too, so I am thinking if we have to document so basic things we have to document more things too... hmm

@zheeeng zheeeng closed this as completed Jan 7, 2019
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

2 participants