AddRequestHeader
添加HTTP请求头的值,它不会覆盖原有值,而是添加。
Example
package main
import (
"github.com/vicanso/elton"
"github.com/vicanso/elton/middleware"
)
func main() {
e := elton.New()
e.Use(middleware.NewDefaultResponder())
e.GET("/", func(c *elton.Context) (err error) {
c.AddRequestHeader("User-Agent", "go-agent")
c.Body = c.Request.Header
return
})
err := e.ListenAndServe(":3000")
if err != nil {
panic(err)
}
}