-
Notifications
You must be signed in to change notification settings - Fork 42
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
How to set QueryParams on GET #31
Comments
To ask a less dumb question - is there a way to do it besides in the GET URL? |
The first way is add Query string in the GET URL. Try the following example: func TestBasicHelloWorld(t *testing.T) {
r := gofight.New()
r.GET("/?a=b&foo=bar").
// turn on the debug mode.
SetDebug(true).
Run(BasicEngine(), func(r gofight.HTTPResponse, rq gofight.HTTPRequest) {
assert.Equal(t, "Hello World", r.Body.String())
assert.Equal(t, http.StatusOK, r.Code)
})
} The second way is implement new func |
@jgoodall I will implement new func |
Yes, putting in URL works fine, just a little unreadable! Thanks, looking forward to the new |
@jgoodall Update to https://github.com/appleboy/gofight#set-query-string func TestQueryString(t *testing.T) {
r := gofight.New()
r.GET("/hello").
SetQUERY(gofight.H{
"a": "1",
"b": "2",
}).
Run(BasicEngine, func(r HTTPResponse, rq HTTPRequest) {
assert.Equal(t, http.StatusOK, r.Code)
})
} |
Great - thank you. Just noticed that |
@jgoodall Good Point. I will change it later. |
I see how to set form and json for POSTs, but how can I set query params on a get request?
The text was updated successfully, but these errors were encountered: