ginadapter

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

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

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

func StartBuffered(r *gin.Engine, options ...awslambda.Option)

StartBuffered starts the Lambda loop in BUFFERED mode with the given Gin engine.

func StartStream

func StartStream(r *gin.Engine, options ...lambda.Option)

StartStream starts the Lambda loop in STREAM_RESPONSE mode with the given Gin engine.

func StreamResponse

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.

Jump to

Keyboard shortcuts

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