-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[BUG] mvc can not get query param #1566
Comments
I dont understand @ghost-void, the example runs here: package main
import (
"fmt"
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/mvc"
)
func main() {
app := newApp()
app.Listen(":8080")
}
func newApp() *iris.Application {
app := iris.New()
mvc.Configure(app.Party("/user"), func(m *mvc.Application) {
m.Handle(new(userController))
})
return app
}
type userController struct{}
func (c *userController) Get(req struct {
Start int `url:"start"`
Limit int `url:"limit"`
}) string {
return fmt.Sprintf("Start: %d | Limit: %d\n", req.Start, req.Limit)
} What version of Iris are u using? You should always try $ cd your_project
$ go get -u github.com/kataras/iris/v12@master
$ go run . |
Sorry for that i missed some points. I found that if controller has a public struct field, it happened.
|
@ghost-void This is an expected behavior and it's the correct one. Let me explain, This happens because mvc.Configure(app.Party("/user"), func(m *mvc.Application) {
m.HandleError(func(ctx iris.Context, err error) {
// this will print: schema: invalid path "start" (and 1 other error)
println(err.Error())
})
m.Handle(new(userController))
}) Solutions by you:
What I can do:
Stay tuned, I will push examples and implement both of the above ^ |
…users and ignore unknown url query parameters instead of giving an ErrPath relative to: kataras/iris#1566
@ghost-void if you upgrade to the latest |
It works, nice job! |
Thanks @ghost-void ! |
Describe the bug
route can not handle query param when using mvc controller
To Reproduce
Steps to reproduce the behavior:
1.
The text was updated successfully, but these errors were encountered: