This is what my controller looks like
func (o *MyController) Get() {
uri := o.Ctx.Input.URI()
beego.Trace(uri)
}
Now if i make a request to the corresponding endpoint for example "http://localhost:8081/path?key=value", i get the correct value for uri
But if i test it with following code
func TestGet(t *testing.T) {
Convey("valid request case", t, func() {
w := httptest.NewRecorder()
uri := "/path?key=value"
r, _ := http.NewRequest("GET", uri, nil)
beego.BeeApp.Handlers.ServeHTTP(w, r)
So(w.Code, ShouldEqual, 200)
})
}
uri in controller is empty string
However, o.Ctx.Request.URL has correct value i.e. '/path'
Aucun commentaire:
Enregistrer un commentaire