Closed everton-sales-branco closed 7 years ago
You can use a struct for it.
Von meinem iPhone gesendet
Am 06.07.2017 um 16:11 schrieb EvertonSalesBranco notifications@github.com:
Hi guys, To get values in a query of GET method, like: "?searchPhrase[fields][]=name&searchPhrase[fields][]=registry&test=abc"
I did something like this: ctx.Request.Form["searchPhrase[fields][]"][0] -> name ctx.Request.Form["searchPhrase[fields][]"][1] -> registry
I think is a good idea do some wrapper to that, I right?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
@Dexus Is there any function to it?
I mean yes but I have just no computer to look. I mean there is also an example or maybe it was on the iris website as long as it was available...
Von meinem iPhone gesendet
Am 06.07.2017 um 20:17 schrieb EvertonSalesBranco notifications@github.com:
@Dexus Is there some function to it?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
I never used it, but I think it was something like this:
type FormObject struct {
Username string `form:"username"`
Password string `form:"password"`
}
func yourRouteFunction(c context.Context) {
form := &FormObject{}
c.ReadForm(form)
}
Try this: https://github.com/google/go-querystring/issues/7#issuecomment-259792233
It's not yet for GET Params (Querystring) implemented if looked just into it. But we can do it.
Or even better maybe: https://github.com/pasztorpisti/qs
When you use ctx.Request.URL.Query() and qs or schema you don't need to build this crap wrapper...
Ok, qs is the solution.
Internal notice:
Add a new context function for get params to parse into a struct. Also add a shortcut function to get fields only for querystrings, because ctx.request.Form
(ctx.FormValue('namestring')
or ctx.FormValues()
) overwrite same name fields with post/put params.
Hi guys, To get values in a query of GET method, like: "?searchPhrase[fields][]=name&searchPhrase[fields][]=registry&test=abc"
I did something like this: ctx.Request.Form["searchPhrase[fields][]"][0] -> name ctx.Request.Form["searchPhrase[fields][]"][1] -> registry
I think is a good idea do some wrapper to that, I right?