ZH_Params

Lunny Xiao edited this page Apr 7, 2015 · 3 revisions
  • Params Params让你能够获得路由匹配的参数。对于命名路由:
type Action struct {
    tango.Params
}
func (a *Action) Get() string {
    return a.Params.Get(":name")
}

func main() {
    t := tango.Classic()
    t.Get("/:name", new(Action))
    t.Run()
}

对于正则路由,也通过:name来获得

type Action struct {
    tango.Params
}
func (a *Action) Get() string {
    return a.Params.Get(":name")
}

func main() {
    t := tango.Classic()
    t.Post("/(:name.*)", new(Action))
    t.Run()
}
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.