Documentation
¶
Index ¶
- type Checker
- type Debug
- type ErrorResponse
- type ErrorResponseError
- type Function
- func (e *Function) AddCheckers(checkers ...Checker) *Function
- func (e *Function) AddProviders(providers ...Provider) *Function
- func (e *Function) Handler(ctx context.Context, in events.APIGatewayProxyRequest) (out events.APIGatewayProxyResponse, _ error)
- func (e *Function) SetDebug(debug Debug) *Function
- func (e *Function) SetRequestParser(reqParser RequestParser) *Function
- func (e *Function) Start()
- type Handler
- type Headers
- type Path
- type PathParameters
- type Provider
- type QueryString
- type RequestContext
- type RequestParser
- type SerializedResponse
- type StageVariables
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker func(ctx context.Context, in *events.APIGatewayProxyRequest, req interface{}) (context.Context, error)
Checker implements a check on a request, usually for authentication or validation. It can optionally also add values to the context.
type ErrorResponse ¶
type ErrorResponse struct { StatusCode int `json:"statusCode"` PublicMessage string `json:"publicMessage"` RequestID string `json:"requestId"` Errors []*ErrorResponseError `json:"errors,omitempty"` // included only if debug context value is set to true }
ErrorResponse describes an error response.
type ErrorResponseError ¶
type ErrorResponseError struct { Error string `json:"error"` StackTrace []string `json:"stackTrace"` }
ErrorResponseError is an entry in the Errors section of ErrorResponse.
type Function ¶
type Function struct {
// contains filtered or unexported fields
}
Function sets up a Lambda function handler.
func NewFunction ¶
NewFunction initializes a new Function.
func (*Function) AddCheckers ¶
AddCheckers adds one or more Checker(s) to the Function.
func (*Function) AddProviders ¶
AddProviders adds one or more Provider(s) to the Function.
func (*Function) Handler ¶
func (e *Function) Handler(ctx context.Context, in events.APIGatewayProxyRequest) (out events.APIGatewayProxyResponse, _ error)
Handler provides a handler function suitable for lambda.Start().
func (*Function) SetDebug ¶
SetDebug enables or disables additional debug information. Default is disabled.
func (*Function) SetRequestParser ¶
func (e *Function) SetRequestParser(reqParser RequestParser) *Function
SetRequestParser sets a custom RequestParser. Default is JSON.
type Headers ¶
type Headers struct {
// contains filtered or unexported fields
}
Headers provides access to request headers, as original map or case-insensitive getters.
func GetHeaders ¶
GetHeaders returns the Headers stored in context.
func (Headers) Get ¶
Get returns a single value corresponding to the given key, with case-insensitive matching. If the key is not present, it returns "". If the key has multiple values, it returns the last one.
func (Headers) GetMulti ¶
Get returns the values corresponding to the given key, with case-insensitive matching. If the key is not present, it returns []string{}. If the key has multiple values, it returns all of them.
type PathParameters ¶
type PathParameters struct {
// contains filtered or unexported fields
}
PathParameters provides access to path parameters, as original map or case-insensitive getter.
func GetPathParameters ¶
func GetPathParameters(ctx context.Context) *PathParameters
GetPathParameters returns the PathParameters stored in context.
type Provider ¶
Provider is a function that populates the Context with some values.
func RequestProvider ¶
func RequestProvider(k interface{}, f func() interface{}) Provider
RequestProvider returns a Provider that generates a new k/v pair for every requests, obtaining v from f.
func SingletonProvider ¶
func SingletonProvider(k, v interface{}) Provider
SingletonProvider returns a Provider that adds the given k/v pair to the context.
type QueryString ¶
type QueryString struct {
// contains filtered or unexported fields
}
QueryString provides access to query string parameters, as original map or case-insensitive getters.
func GetQueryString ¶
func GetQueryString(ctx context.Context) *QueryString
GetQueryString returns the QueryString stored in context.
func (QueryString) Get ¶
Get returns a single value corresponding to the given key, with case-insensitive matching. If the key is not present, it returns "". If the key has multiple values, it returns the last one.
func (QueryString) GetMulti ¶
Get returns the values corresponding to the given key, with case-insensitive matching. If the key is not present, it returns []string{}. If the key has multiple values, it returns all of them.
type RequestContext ¶
type RequestContext = events.APIGatewayProxyRequestContext
RequestContext is an alias for events.APIGatewayProxyRequestContext.
func GetRequestContext ¶
func GetRequestContext(ctx context.Context) *RequestContext
GetRequestContext returns the RequestContext stored in context.
type RequestParser ¶
type RequestParser func(context.Context, reflect.Type, *events.APIGatewayProxyRequest) (interface{}, error)
RequestParser describes a custom request parser. The default is JSON.
func FormRequestParser ¶
func FormRequestParser() RequestParser
FormRequestParser returns a RequestParser for form encoded requests. It uses gorilla/schema to map values to a struct.
func JSONRequestParser ¶
func JSONRequestParser() RequestParser
JSONRequestParser returns a RequestParser for JSON requests.
type SerializedResponse ¶
SerializedResponse allows returning a non-JSON response body, passed through as it is.
type StageVariables ¶
type StageVariables struct {
// contains filtered or unexported fields
}
StageVariables provides access to stage variables, as original map or case-insensitive getter.
func GetStageVariables ¶
func GetStageVariables(ctx context.Context) *StageVariables
GetStageVariables returns the GetStageVariables stored in context.