Documentation
¶
Overview ¶
Package club provides middleware for use in HTTP API servers and gateways.
Index ¶
Constants ¶
const (
RequestContextHeader = "x-amzn-request-context"
)
Variables ¶
This section is empty.
Functions ¶
func Bouncer ¶
Bouncer returns a HTTP Handler middleware function that adds the TLS client certificate from the request to the x-amzn-request-context header.
func Interceptor ¶
Interceptor is a HTTP handler middleware function that parses the `x-amzn-request-context` header into the RequestContext struct. The header is expected to contain a JSON encoded RequestContext.
If the header is missing or malformed, the middleware responds with a 401 Unauthorized error.
Types ¶
type RequestContext ¶
type RequestContext struct {
Namespace uuid.UUID
ClientCertificate *x509.Certificate
ClientPublicKey *ecdsa.PublicKey
SourceIP string `json:"sourceIp"`
UserAgent string `json:"userAgent"`
}
func FromContext ¶ added in v1.4.0
func FromContext(ctx context.Context) (r *RequestContext, ok bool)
FromContext identifies a client from the request context. Interceptor must run before this function is called for a request.
func MustFromContext ¶ added in v1.7.2
func MustFromContext(ctx context.Context) *RequestContext
MustFromContext is identical to FromContext, except that it panics if the context doesn't have a RequestContext object.
func (RequestContext) MarshalJSON ¶ added in v1.7.0
func (r RequestContext) MarshalJSON() ([]byte, error)
func (*RequestContext) UnmarshalJSON ¶ added in v1.7.0
func (r *RequestContext) UnmarshalJSON(data []byte) error