SetRequestHeader
设置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.SetRequestHeader("User-Agent", "go-agent")
c.Body = c.GetRequestHeader("User-Agent")
return
})
err := e.ListenAndServe(":3000")
if err != nil {
panic(err)
}
}