AWS ApiGatewayV2 Go
Uses aws-lambda-go-api-proxy to allow you to run a Go API with API Gateway V2.
So you write your Go function as you normally would and then use the package to handle the API Gateway V2 event.
import ( "github.com/aws/aws-lambda-go/lambda" "github.com/awslabs/aws-lambda-go-api-proxy/httpadapter")
func router() *http.ServeMux { mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) w.Write([]byte(`{"message": "hello world"}`)) })
return mux}
func main() { lambda.Start(httpadapter.NewV2(router()).ProxyWithContext)}const api = new sst.aws.ApiGatewayV2("GoApi");
api.route("$default", { handler: "src/", runtime: "go",});View the full example.