Documentation ¶
Index ¶
- Constants
- func NewErrBadRequest(format string, options ...errorz.Option) error
- func NewErrForbidden(format string, options ...errorz.Option) error
- func NewErrUnauthorized(format string, options ...errorz.Option) error
- func NoUnmarshalBody(u *jsonHTTPRequestUnmarshaler)
- func NoUnmarshalPathParameters(u *jsonHTTPRequestUnmarshaler)
- func NoUnmarshalQueryStringParameters(u *jsonHTTPRequestUnmarshaler)
- func RequireExtractUser(u *jsonHTTPRequestUnmarshaler)
- func WrapErrBadRequest(err error, options ...errorz.Option) error
- func WrapErrForbidden(err error, options ...errorz.Option) error
- func WrapErrUnauthorized(err error, options ...errorz.Option) error
- type HTTPEndpoint
- type HTTPErrorMarshaler
- type HTTPMethod
- type HTTPRequestAuthorizer
- type HTTPRequestAuthorizerFunc
- type HTTPRequestContext
- type HTTPRequestUnmarshaler
- type HTTPResponseContext
- type HTTPResponseMarshaler
- type HTTPRouteKey
- type HTTPRouter
- func (r *HTTPRouter) GetEndpoints() []*HTTPEndpoint
- func (r *HTTPRouter) Handler(ctx context.Context, event events.APIGatewayV2HTTPRequest) (hEvent events.APIGatewayV2HTTPResponse, hErr error)
- func (r *HTTPRouter) Register(endpoint *HTTPEndpoint) *HTTPRouter
- func (r *HTTPRouter) SetInjector(injector injectz.Injector) *HTTPRouter
- func (r *HTTPRouter) ShallowClone() *HTTPRouter
- type JSONHTTPRequestUnmarshalerOption
Constants ¶
const ( ErrIDBadRequest = errorz.ID("bad-request") ErrIDForbidden = errorz.ID("forbidden") )
Known error IDs.
Variables ¶
This section is empty.
Functions ¶
func NewErrBadRequest ¶
NewErrBadRequest creates a new bad request error.
func NewErrForbidden ¶
NewErrForbidden creates a new forbidden error.
func NewErrUnauthorized ¶
NewErrUnauthorized creates a new unauthorized error.
func NoUnmarshalBody ¶
func NoUnmarshalBody(u *jsonHTTPRequestUnmarshaler)
NoUnmarshalBody describes a JSONHTTPRequestUnmarshalerOption.
func NoUnmarshalPathParameters ¶
func NoUnmarshalPathParameters(u *jsonHTTPRequestUnmarshaler)
NoUnmarshalPathParameters describes a JSONHTTPRequestUnmarshalerOption.
func NoUnmarshalQueryStringParameters ¶
func NoUnmarshalQueryStringParameters(u *jsonHTTPRequestUnmarshaler)
NoUnmarshalQueryStringParameters describes a JSONHTTPRequestUnmarshalerOption.
func RequireExtractUser ¶
func RequireExtractUser(u *jsonHTTPRequestUnmarshaler)
RequireExtractUser describes a JSONHTTPRequestUnmarshalerOption.
func WrapErrBadRequest ¶
WrapErrBadRequest wraps an error as bad request error.
func WrapErrForbidden ¶
WrapErrForbidden wraps an error as forbidden error.
Types ¶
type HTTPEndpoint ¶
type HTTPEndpoint struct {
// contains filtered or unexported fields
}
HTTPEndpoint describes an endpoint.
func NewHTTPEndpoint ¶
func NewHTTPEndpoint( rawRouteKey string, requestAuthorizer HTTPRequestAuthorizer, requestUnmarshaler HTTPRequestUnmarshaler, responseMarshaler HTTPResponseMarshaler, errorMarshaler HTTPErrorMarshaler, handlerFunc interface{}) *HTTPEndpoint
NewHTTPEndpoint initializes a new HTTPEndpoint.
func (*HTTPEndpoint) GetRouteKey ¶
func (e *HTTPEndpoint) GetRouteKey() *HTTPRouteKey
GetRouteKey returns the route key.
type HTTPErrorMarshaler ¶
type HTTPErrorMarshaler interface {
Marshal(ctx context.Context, err error) *events.APIGatewayV2HTTPResponse
}
HTTPErrorMarshaler describes a marshaler for a HTTP error.
func NewJSONHTTPErrorMarshaler ¶
func NewJSONHTTPErrorMarshaler() HTTPErrorMarshaler
NewJSONHTTPErrorMarshaler initializes a new HTTPErrorMarshaler.
type HTTPMethod ¶
type HTTPMethod string
HTTPMethod describes a HTTP method.
const ( Any HTTPMethod = "ANY" Delete HTTPMethod = "DELETE" Get HTTPMethod = "GET" Head HTTPMethod = "HEAD" Options HTTPMethod = "OPTIONS" Patch HTTPMethod = "PATCH" Post HTTPMethod = "POST" Put HTTPMethod = "PUT" )
Known HTTP methods.
func (HTTPMethod) String ¶
func (m HTTPMethod) String() string
String implements the fmt.Stringer interface.
func (HTTPMethod) Valid ¶
func (m HTTPMethod) Valid() bool
Valid implements the vz.SimpleValidator interface.
type HTTPRequestAuthorizer ¶
HTTPRequestAuthorizer describes an unmarshaler for a HTTP request.
func NewStaticAPIKeyHTTPRequestAuthorizer ¶
func NewStaticAPIKeyHTTPRequestAuthorizer(apiKey string) HTTPRequestAuthorizer
NewStaticAPIKeyHTTPRequestAuthorizer initializes a new HTTPRequestAuthorizer
type HTTPRequestAuthorizerFunc ¶
HTTPRequestAuthorizerFunc implements the HTTPRequestAuthorizer interface.
type HTTPRequestContext ¶
type HTTPRequestContext struct {
// contains filtered or unexported fields
}
HTTPRequestContext describes the context for a HTTP request.
func GetHTTPRequestContext ¶
func GetHTTPRequestContext(ctx context.Context) *HTTPRequestContext
GetHTTPRequestContext extracts the *HTTPRequestContext from context, panics on error.
func (*HTTPRequestContext) GetEvent ¶
func (c *HTTPRequestContext) GetEvent() *events.APIGatewayV2HTTPRequest
GetEvent returns the original APIGatewayV2HTTPRequest event.
type HTTPRequestUnmarshaler ¶
type HTTPRequestUnmarshaler interface { GetRequestType() *reflect.Type Unmarshal(ctx context.Context) (interface{}, error) }
HTTPRequestUnmarshaler describes an unmarshaler for a HTTP request.
func NewJSONHTTPRequestUnmarshaler ¶
func NewJSONHTTPRequestUnmarshaler(reqTemplate interface{}, options ...JSONHTTPRequestUnmarshalerOption) HTTPRequestUnmarshaler
NewJSONHTTPRequestUnmarshaler initializes a new HTTPRequestUnmarshaler.
func NewNoBodyHTTPRequestUnmarshaler ¶
func NewNoBodyHTTPRequestUnmarshaler(isStrict bool) HTTPRequestUnmarshaler
NewNoBodyHTTPRequestUnmarshaler initializes a new HTTPRequestUnmarshaler.
type HTTPResponseContext ¶
type HTTPResponseContext struct {
// contains filtered or unexported fields
}
HTTPResponseContext describes the context for a HTTP response.
func GetHTTPResponseContext ¶
func GetHTTPResponseContext(ctx context.Context) *HTTPResponseContext
GetHTTPResponseContext extracts the *HTTPResponseContext from context, panics on error.
func (*HTTPResponseContext) AddCookie ¶
func (c *HTTPResponseContext) AddCookie(cookie http.Cookie)
AddCookie adds a cookie to the response.
func (*HTTPResponseContext) GetHeaders ¶
func (c *HTTPResponseContext) GetHeaders() http.Header
GetHeaders returns the editable response headers.
func (*HTTPResponseContext) SetStatus ¶
func (c *HTTPResponseContext) SetStatus(status int)
SetStatus sets the response status.
type HTTPResponseMarshaler ¶
type HTTPResponseMarshaler interface { GetResponseType() *reflect.Type Marshal(ctx context.Context, resp interface{}) *events.APIGatewayV2HTTPResponse }
HTTPResponseMarshaler describes a marshaler for a HTTP response.
func NewJSONHTTPResponseMarshaler ¶
func NewJSONHTTPResponseMarshaler(respTemplate interface{}) HTTPResponseMarshaler
NewJSONHTTPResponseMarshaler initializes a new HTTPResponseMarshaler.
func NewNoBodyHTTPResponseMarshaler ¶
func NewNoBodyHTTPResponseMarshaler() HTTPResponseMarshaler
NewNoBodyHTTPResponseMarshaler initializes a new HTTPResponseMarshaler.
type HTTPRouteKey ¶
type HTTPRouteKey struct { Raw string IsDefault bool Method HTTPMethod Path string }
HTTPRouteKey describes a parsed HTTP route key.
func ParseHTTPRouteKey ¶
func ParseHTTPRouteKey(rawRouteKey string) (*HTTPRouteKey, error)
ParseHTTPRouteKey parses a HTTP route key. Note that the parsing logic is not particularly strict, rather designed to prevent accidental mistakes.
type HTTPRouter ¶
type HTTPRouter struct {
// contains filtered or unexported fields
}
HTTPRouter implements a HTTP router.
func (*HTTPRouter) GetEndpoints ¶
func (r *HTTPRouter) GetEndpoints() []*HTTPEndpoint
GetEndpoints gets a slice of registered endpoints.
func (*HTTPRouter) Handler ¶
func (r *HTTPRouter) Handler(ctx context.Context, event events.APIGatewayV2HTTPRequest) (hEvent events.APIGatewayV2HTTPResponse, hErr error)
Handler provides a handler function that can be registered with the Lambda SDK.
func (*HTTPRouter) Register ¶
func (r *HTTPRouter) Register(endpoint *HTTPEndpoint) *HTTPRouter
Register registers an endpoint.
func (*HTTPRouter) SetInjector ¶
func (r *HTTPRouter) SetInjector(injector injectz.Injector) *HTTPRouter
SetInjector sets the (optional) context injector.
func (*HTTPRouter) ShallowClone ¶
func (r *HTTPRouter) ShallowClone() *HTTPRouter
ShallowClone returns a shallow clone of the router.
type JSONHTTPRequestUnmarshalerOption ¶
type JSONHTTPRequestUnmarshalerOption func(u *jsonHTTPRequestUnmarshaler)
JSONHTTPRequestUnmarshalerOption describe an option for jsonHTTPRequestUnmarshaler.