Documentation ¶
Overview ¶
Package asgard provides middleware for use in HTTP API servers and reverse-proxies. In Norse mythology, Heimdallr is the gatekeeper of Bifröst and Hofund is his sword.
Heimdallr returna a HTTP Handler middleware function that parses a header into a RequestContext. Hofund returns a HTTP Handler middleware function that writes a RequestContext into a header from a client's TLS certificate.
Index ¶
Constants ¶
const (
DefaultRequestContextHeader = "x-amzn-request-context"
)
Variables ¶
This section is empty.
Functions ¶
func Heimdallr ¶ added in v1.10.2
Heimdallr returns a HTTP handler middleware function that parses headerName as JSON into the RequestContext struct. If the header is missing or malformed, the middleware responds with a 401 Unauthorized error.
Types ¶
type RequestContext ¶
type RequestContext struct { ClientCertificate *bifrost.Certificate SourceIP string `json:"sourceIp"` UserAgent string `json:"userAgent"` }
func FromContext ¶
func FromContext(ctx context.Context) (r *RequestContext, ok bool)
FromContext returns a *RequestContext from http.Request.Context. If it doesn't exist (i.e. Heimdall hasn't run yet), the second return parameter is false.
func MustFromContext ¶
func MustFromContext(ctx context.Context) *RequestContext
MustFromContext is identical to FromContext, except that it panics if the context doesn't have a RequestContext object. Heimdall must have run before this function is called.
func (RequestContext) MarshalJSON ¶
func (r RequestContext) MarshalJSON() ([]byte, error)
func (*RequestContext) UnmarshalJSON ¶
func (r *RequestContext) UnmarshalJSON(data []byte) error