Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIGatewayV1 ¶
type APIGatewayV1 []WithResponse[events.APIGatewayProxyRequest, events.APIGatewayProxyResponse]
func CommonAPIGatewayV1 ¶
func CommonAPIGatewayV1(outputter metrics.Outputter) APIGatewayV1
CommonAPIGatewayV1 returns a slice of common middleware for handlers of events.APIGatewayProxyRequest that return events.APIGatewayProxyResponse
type NoResponse ¶
type NoResponse[E any] interface { // Wrap returns a function that receives an event and returns an error. The next parameter is the next function to // be called in the chain of middleware and handlers, and should always be called unless the desired outcome is to // prevent the request from proceeding (i.e. a validation middleware could return an error straight away and // prevent an invalid request from being further processed) Wrap(next func(context.Context, E) error) func(context.Context, E) error }
NoResponse [E any] interface should be implemented for middleware of handlers of event type E that do not return a response.
func Common ¶
func Common[E any](outputter metrics.Outputter) []NoResponse[E]
Common [E any] returns a slice of common middleware for handlers of event type E that do not return a response.
func NewContext ¶
func NewContext[E any]() NoResponse[E]
NewContext returns an implementation of NoResponse for the context middleware.
The context middleware adds additional information to the context of each request using the github.com/ellogroup/ello-golang-ctx/logctx package. This includes at the very least a request id.
func NewMetrics ¶
func NewMetrics[E any](outputter metrics.Outputter) NoResponse[E]
NewMetrics returns an implementation of NoResponse for the metrics middleware.
The metrics middleware outputs the request start and end. The request start output contains the event and the request end output contains the duration of the request.
Outputters need to implement the `metrics.Outputter` interface from the github.com/ellogroup/ello-golang-metrics/metrics package.
type S3 ¶
type S3 []NoResponse[events.S3Event]
type SNS ¶
type SNS []NoResponse[events.SNSEvent]
type SQS ¶
type SQS []NoResponse[events.SQSEvent]
type WithResponse ¶
type WithResponse[E, R any] interface { // Wrap returns a function that receives an event and returns a response/error. The next parameter is the next // function to be called in the chain of middleware and handlers, and should always be called unless the desired // outcome is to prevent the request from proceeding (i.e. a validation middleware could return an error straight // away and prevent an invalid request from being further processed) Wrap(next func(context.Context, E) (R, error)) func(context.Context, E) (R, error) }
WithResponse [E, R any] interface should be implemented for middleware of handlers of event type E that return a response type R.
func CommonWithResponse ¶
func CommonWithResponse[E, R any](outputter metrics.Outputter) []WithResponse[E, R]
CommonWithResponse [E, R any] returns a slice of common middleware for handlers of event type E that return a response type R.
func NewContextWithResponse ¶
func NewContextWithResponse[E, R any]() WithResponse[E, R]
NewContextWithResponse returns an implementation of WithResponse for the context middleware.
The context middleware adds additional information to the context of each request using the github.com/ellogroup/ello-golang-ctx/logctx package. This includes at the very least a request id.
For API Gateway v1 requests the context also includes the method, domain and path of the request. The response is also updated to include the request id within the header `x-request-id`.
func NewMetricsWithResponse ¶
func NewMetricsWithResponse[E, R any](outputter metrics.Outputter) WithResponse[E, R]
NewMetricsWithResponse returns an implementation of WithResponse for the metrics middleware.
The metrics middleware outputs the request start and end. The request start output contains the event and the request end output contains the duration of the request.
For API Gateway v1 requests the output also contains the status code of the response.
Outputters need to implement the `metrics.Outputter` interface from the github.com/ellogroup/ello-golang-metrics/metrics package.