header
header is a directive executor who decodes a field from HTTP headers, i.e. http.Request.Header
.
Definition
Name: "header"
Args: KEY1 [,KEY2 [,KEY3, ...]]
header will examine values of the keys one by one (KEY1 -> KEY2 -> ...) from the HTTP headers, the first non-empty value will be used to set the corresponding field of the input struct.
caution
The keys will be normalized, see CanonicalHeaderKey
, e.g. the header key of Content-Type
and content-type
are the same, which works like case-insensitive.
Usage
type TokenInput struct {
Token string `in:"header=x-api-token,Authorization"`
}
Request (Header) | TokenInput |
---|---|
|
|
|
|
|
|
|
|