GetRequestHeader

从HTTP请求头中获取相应的值。

Example

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