MergeHeader

合并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. h := make(http.Header)
  11. h.Add("X-Response-Id", "1")
  12. h.Add("X-Response-Id", "2")
  13. c.MergeHeader(h)
  14. c.Body = c.Header()
  15. return
  16. })
  17. err := e.ListenAndServe(":3000")
  18. if err != nil {
  19. panic(err)
  20. }
  21. }