AddHeader

添加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.AddHeader("X-Response-Id", "1")
  11. c.AddHeader("X-Response-Id", "2")
  12. c.Body = c.Header()
  13. return
  14. })
  15. err := e.ListenAndServe(":3000")
  16. if err != nil {
  17. panic(err)
  18. }
  19. }