club

package
v1.8.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2023 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package club provides middleware for use in HTTP API servers and gateways.

Index

Constants

View Source
const (
	RequestContextHeader = "x-amzn-request-context"
)

Variables

This section is empty.

Functions

func Bouncer

func Bouncer(next http.Handler) http.Handler

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

func Interceptor(next http.Handler) http.Handler

Interceptor is a HTTP handler middleware function that parses the x-amzn-request-context request header. The header is expected to contain a JSON encoded RequestContext. The identity namespace, client's UUID, and certificate are added to the request context.

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL