-
-
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
When I used router in my codes, found some strange rule that maybe need to ask for help about it. #1349
Comments
Hello @conero , The Example: 1. mvc.New(app.Party("/api/data/{model:string}/{action:string}")).Handle(new(Data))
// [...]
func (c *Data) AnyBy(s string) {
}
TIP: use UPDATE: The issue you are facing is coming from the fact that you register a mvc.New(app.Party("/api/data").Handle(new(Data))
// [...]
func (c *Data) AnyBy(model, action, id string) {
c.Model = model
c.Action = action
// c.ID = c.Ctx.Params().Get("param1")
c.ID = id
c.Ctx.Writef("%#+v\n", c)
} TIP 2: You can also bind dynamic function which will set your model on every controller, based on the context, e.g. iris/_examples/hero/smart-contract/main.go Lines 93 to 108 in 7529b2c
|
Big thanks to @kataras, bro. |
You are welcome @conero, sorry for the delay, I had some interviews to do. I've just pushed a commit which supports the above case you posted as well. |
Former-commit-id: 1e2c7185fc3c536ceb8b269c75b9a2c19323960b
Code like this:
Then made the request:
GET: http://127.0.0.1:9960/api/data/user/list/2099
Get response
Problem in this case:
AnyBy(id string)
id should be2099
, butuser
c.Ctx.Params().Get("id")
is empty mayby should be2099
func (c *Data) BeforeActivation(b mvc.BeforeActivation)
c.Ctx isnil
So I had to use
path.Base
to get the trueid
, I don't know if I missed some thing but the help.The text was updated successfully, but these errors were encountered: