Need help with gateway?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

612 Stars 62 Forks MIT License 38 Commits 16 Opened issues


Drop-in replacement for Go net/http when running in AWS Lambda & API Gateway

Services available


Need anything else?

Contributors list

Package gateway provides a drop-in replacement for net/http's

for use in AWS Lambda & API Gateway, simply swap it out for
. Extracted from Up which provides additional middleware features and operational functionality.

There are two versions of this library, version 1.x supports AWS API Gateway 1.0 events used by the original REST APIs, and 2.x which supports 2.0 events used by the HTTP APIs. For more information on the options read Choosing between HTTP APIs and REST APIs on the AWS documentation website.


To install version 1.x for REST APIs.

go get

To install version 2.x for HTTP APIs.

go get


package main

import ( "fmt" "log" "net/http" "os"



func main() { http.HandleFunc("/", hello) log.Fatal(gateway.ListenAndServe(":3000", nil)) }

func hello(w http.ResponseWriter, r *http.Request) { // example retrieving values from the api gateway proxy request context. requestContext, ok := gateway.RequestContext(r.Context()) if !ok || requestContext.Authorizer["sub"] == nil { fmt.Fprint(w, "Hello World from Go") return }

userID := requestContext.Authorizer["sub"].(string)
fmt.Fprintf(w, "Hello %s from Go", userID)



We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.