How to retrieve headers data value from client API using Go language?
I'm using beego framework (beego.me)
and here is sample result to retrieve data from body
func (u *UserController) Post() {
var user models.User
json.Unmarshal(u.Ctx.Input.RequestBody, &user)
uid := models.AddUser(user)
u.Data["json"] = map[string]string{"uid": uid}
u.ServeJSON()
}
According to the docs, you can do this:
log.Println(u.Ctx.Input.Header("X-My-Header"))
All headers at once can be obtained from an *http.Request:
log.Println(u.Ctx.Request.Header)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With