Documentation
¶
Index ¶
- func BufferedResponse(ctx context.Context) *events.LambdaFunctionURLResponse
- func JSONErrorHandler() gin.HandlerFunc
- func Request(ctx context.Context) *events.LambdaFunctionURLRequest
- func StartBuffered(r *gin.Engine, options ...awslambda.Option)
- func StartStream(r *gin.Engine, options ...lambda.Option)
- func StreamResponse(ctx context.Context) *events.LambdaFunctionURLStreamingResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BufferedResponse ¶
func BufferedResponse(ctx context.Context) *events.LambdaFunctionURLResponse
BufferedResponse returns the pending events.LambdaFunctionURLResponse from context.
If the gin handlers passed to StartBuffered or StartStream need access to the pending response, it can be retrieved from context with this method.
func JSONErrorHandler ¶ added in v0.1.8
func JSONErrorHandler() gin.HandlerFunc
JSONErrorHandler is a middleware that makes sure errors are always returned to caller as JSON content.
Useful if your handler is handling API endpoints which are returning JSON responses already. The request chain must have been aborted for the middleware to take action. If status code is not explicitly set, the middleware will set it to http.StatusInternalServerError. If response body is already written or the request has no errors (which implies the request has not been aborted), the middleware will not write any JSON content.
Otherwise, the JSON error message looks like this:
{ "status": 500|400|..., "message": "message describing the error" }
If the error type is gin.ErrorTypeBind or gin.ErrorTypePublic, its message will be returned as the "message" field. Any other error types will be hidden with a default message retrieved from http.StatusText.
func Request ¶
func Request(ctx context.Context) *events.LambdaFunctionURLRequest
Request returns the original events.LambdaFunctionURLRequest from context.
If the gin handlers passed to StartBuffered or StartStream need access to the original invocation, it can be retrieved from context with this method.
func StartBuffered ¶
StartBuffered starts the Lambda loop in BUFFERED mode with the given Gin engine.
func StartStream ¶
StartStream starts the Lambda loop in STREAM_RESPONSE mode with the given Gin engine.
func StreamResponse ¶
func StreamResponse(ctx context.Context) *events.LambdaFunctionURLStreamingResponse
StreamResponse returns the pending events.LambdaFunctionURLStreamingResponse from context.
If the gin handlers passed to StartBuffered or StartStream need access to the pending response, it can be retrieved from context with this method.
Types ¶
This section is empty.