Documentation ¶
Index ¶
- func APIGatewayContext(ctx context.Context) (events.APIGatewayProxyRequestContext, bool)
- func IsLambda() bool
- func LambdaContext(ctx context.Context) (*lambdacontext.LambdaContext, bool)
- func ListenAndServe(addr string, handler http.Handler) error
- func ListenAndServeTLS(addr string, certFile, keyFile string, handler http.Handler) error
- type LambdaAdapter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APIGatewayContext ¶
func APIGatewayContext(ctx context.Context) (events.APIGatewayProxyRequestContext, bool)
APIGatewayContext returns the APIGatewayProxyRequestContext value stored in ctx.
func LambdaContext ¶
func LambdaContext(ctx context.Context) (*lambdacontext.LambdaContext, bool)
LambdaContext return the LambdaContext value stored in ctx.
func ListenAndServe ¶
ListenAndServe calls http.ListenAndServe with handler to handle requests on incoming connections when invoked outside AWS Lambda environment.
If handler is nil, it uses http.DefaultServeMux as default handler.
In AWS Lambda environment it calls lambda.Start with handler to handle requests transparently as if it was working in a non serverless environment. Addr argument is ignored in AWS Lambda.
A trivial example is:
package main import ( "github.com/imdario/gluo" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello from Gluo")) } func main() { gluo.ListenAndServe(":3000", http.HandlerFunc(handler)) }
ListenAndServe always returns a non-nil error. Under AWS Lambda, it always returns nil.
func ListenAndServeTLS ¶
ListenAndServeTLS acts identically to ListenAndServe, except that it expects HTTPS connections. Additionally, files containing a certificate and matching private key for the server must be provided. If the certificate is signed by a certificate authority, the certFile should be the concatenation of the server's certificate, any intermediates, and the CA's certificate.
Types ¶
type LambdaAdapter ¶
LambdaAdapter allows to wrap a http.Handler for working on AWS Lambda.
func (LambdaAdapter) Handle ¶
func (la LambdaAdapter) Handle(ctx context.Context, event events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error)
Handle handles an AWS Lambda request, converting an APIGatewayProxyRequest into a http.Request.