3 Params
Lunny Xiao edited this page 2015-04-08 07:34:14 +08:00
  • Params Params let you access router's matched parameters.
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()
}

For regexp parameters, also use :name` for named matches.

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()
}