Param

获取路由的参数。

Example

  1. // curl http://127.0.0.1:3000/users/me
  2. package main
  3. import (
  4. "github.com/vicanso/elton"
  5. "github.com/vicanso/elton/middleware"
  6. )
  7. func main() {
  8. e := elton.New()
  9. e.Use(middleware.NewDefaultResponder())
  10. e.GET("/users/{type}", func(c *elton.Context) (err error) {
  11. c.Body = c.Param("type")
  12. return
  13. })
  14. err := e.ListenAndServe(":3000")
  15. if err != nil {
  16. panic(err)
  17. }
  18. }