Documentation ¶
Index ¶
- Constants
- Variables
- func LambdaHandler(handler http.Handler, fallback lambdaHandlerFunc) lambdaHandlerFunc
- func Respond(body interface{}, status int, req events.APIGatewayProxyRequest, err error) (events.APIGatewayProxyResponse, error)
- func RespondHTTP(rw http.ResponseWriter, body interface{}, status int)
- func RespondV2(body interface{}, status int, req events.APIGatewayV2HTTPRequest, err error) (events.APIGatewayV2HTTPResponse, error)
- func Serve(req events.APIGatewayProxyRequest, handler http.Handler) (events.APIGatewayProxyResponse, error)
- func ServeV2(req events.APIGatewayV2HTTPRequest, handler http.Handler) (events.APIGatewayV2HTTPResponse, error)
- func SetLogger(l *slogger.SpalkLogger)
- func StartApex(handler http.Handler)
- func StartLambda(handler http.Handler, fallback lambdaHandlerFunc)
- func ToApigRequest(req http.Request) (events.APIGatewayProxyRequest, error)
- func ToStdLibRequest(req events.APIGatewayProxyRequest) (*http.Request, error)
- func ToStdLibRequestV2(req events.APIGatewayV2HTTPRequest) (*http.Request, error)
- func ToStdLibResponse(resp events.APIGatewayProxyResponse) http.Response
- type ResponseWriter
- type ResponseWriterV2
Constants ¶
const SET_COOKIE = "setcookie"
Variables ¶
var ErrNoHandler = errors.New("No handler defined for event of that type")
Functions ¶
func LambdaHandler ¶
LambdaHandler ...
func Respond ¶
func Respond(body interface{}, status int, req events.APIGatewayProxyRequest, err error) (events.APIGatewayProxyResponse, error)
Respond will produce a response that will get formatted such that apigateway will modify it's response to the browser
func RespondHTTP ¶
func RespondHTTP(rw http.ResponseWriter, body interface{}, status int)
RespondHTTP will marshall the response body as JSON and write it to the response writer This function signature was chosen to make it substitutable for http.Error This does not end the requset, but does write the header. Care should be taken to close the response after this has been called
func RespondV2 ¶
func RespondV2(body interface{}, status int, req events.APIGatewayV2HTTPRequest, err error) (events.APIGatewayV2HTTPResponse, error)
RespondV2 will produce a response that will get formatted such that apigateway will modify it's response to the browser
func Serve ¶
func Serve(req events.APIGatewayProxyRequest, handler http.Handler) (events.APIGatewayProxyResponse, error)
Serve handles and responds to the requests using a net/http handler
func ServeV2 ¶
func ServeV2(req events.APIGatewayV2HTTPRequest, handler http.Handler) (events.APIGatewayV2HTTPResponse, error)
ServeV2 handles and responds to the requests using a net/http handler
func SetLogger ¶
func SetLogger(l *slogger.SpalkLogger)
func StartApex ¶
StartApex starts the apex server than marshals requests in/out of the apex shim using stdin/stdout
func StartLambda ¶
StartLambda ...
func ToApigRequest ¶
func ToApigRequest(req http.Request) (events.APIGatewayProxyRequest, error)
func ToStdLibRequest ¶
func ToStdLibRequest(req events.APIGatewayProxyRequest) (*http.Request, error)
ToStdLibRequest converts the parsed json message into the format expected by the std library
func ToStdLibRequestV2 ¶
func ToStdLibRequestV2(req events.APIGatewayV2HTTPRequest) (*http.Request, error)
func ToStdLibResponse ¶
func ToStdLibResponse(resp events.APIGatewayProxyResponse) http.Response
Types ¶
type ResponseWriter ¶
type ResponseWriter struct {
// contains filtered or unexported fields
}
ResponseWriter implements the net/http ResponseWriter interface for using stdlib compliant server libraries with apigateway and lambdas
func (*ResponseWriter) GetResponse ¶
func (rw *ResponseWriter) GetResponse() (events.APIGatewayProxyResponse, error)
GetResponse formats the net/http response to how the response is expected by apigateway
func (*ResponseWriter) Header ¶
func (rw *ResponseWriter) Header() http.Header
Header returns the map that will be sent with WriteHeader
func (*ResponseWriter) WriteHeader ¶
func (rw *ResponseWriter) WriteHeader(status int)
WriteHeader sets the response code in the embeded response object To be compliant with the http spec for the interface it should write the headers to the client, but we can't control that
type ResponseWriterV2 ¶
type ResponseWriterV2 struct {
// contains filtered or unexported fields
}
ResponseWriterV2 implements the net/http ResponseWriterV2 interface for using stdlib compliant server libraries with apigatewayv2 and lambdas
func (*ResponseWriterV2) GetResponse ¶
func (rw *ResponseWriterV2) GetResponse() (events.APIGatewayV2HTTPResponse, error)
GetResponse formats the net/http response to how the response is expected by apigateway
func (*ResponseWriterV2) Header ¶
func (rw *ResponseWriterV2) Header() http.Header
Header returns the map that will be sent with WriteHeader
func (*ResponseWriterV2) WriteHeader ¶
func (rw *ResponseWriterV2) WriteHeader(status int)
WriteHeader sets the response code in the embeded response object To be compliant with the http spec for the interface it should write the headers to the client, but we can't control that