Documentation
¶
Index ¶
- Variables
- func FromCookie(r *http.Request, key string) (string, error)
- func FromHeader(r *http.Request, key, prefix string) (string, error)
- func FromQuery(r *http.Request, key string) (string, error)
- type ArgumentExtractor
- type CookieExtractor
- type Extractor
- type HeaderExtractor
- type Lookup
- type MultiExtractor
Constants ¶
This section is empty.
Variables ¶
var ErrMissingValue = errors.New("no value present in request")
ErrMissingValue can be thrown by follow if value with a HTTP header, the value header needs to be set if value with URL Query, the query value variable is empty if value with a cookie, the value cookie is empty
Functions ¶
func FromCookie ¶
FromCookie get value from Cookie key is a cookie key
func FromHeader ¶
FromHeader get value from header key is a header key, like "Authorization" prefix is a string in the header, like "Bearer", if it is empty, only will return value.
Types ¶
type ArgumentExtractor ¶
type ArgumentExtractor string
ArgumentExtractor extracts a value from request arguments. This includes a POSTed form or GET URL arguments. This extractor calls `ParseMultipartForm` on the request
func (ArgumentExtractor) ExtractToken ¶
func (e ArgumentExtractor) ExtractToken(r *http.Request) (string, error)
type CookieExtractor ¶
type CookieExtractor string
CookieExtractor extracts a value from cookie.
func (CookieExtractor) ExtractToken ¶
func (e CookieExtractor) ExtractToken(r *http.Request) (string, error)
type Extractor ¶
Extractor is an interface for extracting a value from an HTTP request. The ExtractToken method should return a value string or an error. If no value is present, you must return ErrMissingValue.
type HeaderExtractor ¶
type HeaderExtractor struct {
// The key of the header
// Required
Key string
// Strips 'Bearer ' prefix from bearer value string.
// Possible value is "Bearer"
// Optional
Prefix string
}
HeaderExtractor is an extractor for finding a value in a header. Looks at each specified header in order until there's a match
func (HeaderExtractor) ExtractToken ¶
func (e HeaderExtractor) ExtractToken(r *http.Request) (string, error)
type Lookup ¶
type Lookup struct {
// contains filtered or unexported fields
}
Lookup is a tool that looks up the value from http request, such as token
func NewLookup ¶
NewLookup new a lookup. lookup is a string in the form of "<source>:<name>[:<prefix>]" that is used to extract value from the request. use like "header:<name>[:<prefix>],query:<name>,cookie:<name>,param:<name>" Optional, Default value "header:Authorization:Bearer" for json web token. Possible values: - "header:<name>:<prefix>", <prefix> is a special string in the header, Possible value is "Bearer" - "query:<name>" - "cookie:<name>"
type MultiExtractor ¶
type MultiExtractor []Extractor
MultiExtractor tries Extractors in order until one returns a value string or an error occurs
func (MultiExtractor) ExtractToken ¶
func (e MultiExtractor) ExtractToken(req *http.Request) (string, error)