0

I have a Lambda (Go) behind an HTTP API Gateway. Route /webhook is set correctly (payload format 2.0, not $default), but every request to /webhook still triggers my root / handler, im not getting the webhook handler for some reason.

func main() {
    mux := http.NewServeMux()

    mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprint(w, "hello world")
    })

    mux.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {
        w.WriteHeader(http.StatusOK)
    })

    mux.HandleFunc("/webhook", webhookHandler)

    adapter := httpadapter.NewV2(mux)
    lambda.Start(adapter.ProxyWithContext)
}
1
  • The issue is the api gateway's HTTP API sends requests with a base path that does't match your handler paterns. when you use httpadapter.NewV2(), the path from api gateway includes the stage name and reources path structure. Commented Oct 22 at 10:33

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.