ResetHeader

重置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.ResetHeader()
  13. c.Body = c.Header()
  14. return
  15. })
  16. err := e.ListenAndServe(":3000")
  17. if err != nil {
  18. panic(err)
  19. }
  20. }