Hi Guys,
May I know how to read the request header from gin context ? It seems there is only a write header function in the document.
Thanks in advance.
ctx.Request.Header
example:
return func(c *gin.Context) {
c.Writer.Header().Set("X-Revision", "v1.2.3")
c.Next()
}
Excuse me,
should we have a function like
c.GetHeader(key string) string
to easily get the value of specific request header with key ?
@FrozenKP
if values, _ := c.Request.Header[key]; len(values) > 0 {
return values[0]
}
return ""
hmmm... Can I write this as a function and pull request ? I think it would be useful.
@ponypaver @FrozenKP I add new func GetHeader in develop branch. see #839
c.Request.Header.Get("param")
Most helpful comment
c.Request.Header.Get("param")