http://127.0.0.1:8080/x?haha=1
I want to get something like ctx.QueryArgs().Get("haha")
is it possible in golang's fasthttp
package?
http://127.0.0.1:8080/x?haha=1
I want to get something like ctx.QueryArgs().Get("haha")
is it possible in golang's fasthttp
package?
use Peek and PeekMulti
?haha=1
ctx.QueryArgs().Peek("haha")
?haha=1&haha=2
ctx.QueryArgs().PeekMulti("haha")
Some useful methods are declared here: https://github.com/valyala/fasthttp/blob/a1cfe58ca86648c6701f1cb7e8b1587348dd5b9f/args.go#L245
You can retrieve a custom GET, POST PUT parameter using FormValue method:
- GET (Query String such as ?user=a&pass=b);
- POST, PUT body
Literally, from the documentation:
FormValue returns form value associated with the given key.
The value is searched in the following places:
There are more fine-grained methods for obtaining form values:
token = string(ctx.FormValue("token"))
Documentation: https://godoc.org/github.com/valyala/fasthttp#RequestCtx.FormValue
Another option while you don't have the ctx but have ctx.Request
is this:
// somewhere
req := &ctx.Request
.
.
.
// somewhere else
req.URI().QueryArgs().Peek("somekey")