refactor(svelte-netlify): replace the archived Lambda proxy with gateway - #5304
Conversation
github.com/awslabs/aws-lambda-go-api-proxy was archived on 21 May 2025. This recipe used its core package through a local 109-line Fiber v3 adapter, since the library's own Fiber adapter only supports Fiber v2. The official successor, Lambda Web Adapter, is not an option here: it ships as a Lambda layer or container extension and Netlify Functions support neither. github.com/carlmjohnson/gateway is a maintained drop-in for http.ListenAndServe on Lambda that decodes the same events.APIGatewayProxyRequest payload Netlify delivers, so it fits without changing the deployment model. Fiber v3 already exposes an app as an http.Handler via middleware/adaptor, so the local adapter package is no longer needed and is removed. main.go drops from an init/Handler/lambda.Start arrangement to a single gateway.ListenAndServe call. Note the import path: the repository was renamed to earthboundkid/gateway but its go.mod still declares github.com/carlmjohnson/gateway, so that is the path to import. This also clears the module-graph noise that came with the archived library. It bundled adapters for gin, chi, fiber v2, gorilla/mux, iris, echo and negroni in a single go.mod, so importing any part of it pulled the whole framework list into the graph. Gone from `go list -m` now: github.com/awslabs/aws-lambda-go-api-proxy github.com/gofiber/fiber/v2 (11 advisories, 2 critical) github.com/gomarkdown/markdown (4 advisories) github.com/go-chi/chi/v5 (3 advisories) github.com/sirupsen/logrus (2 advisories) None of those were ever compiled into the binary, but they were reported by anything resolving the module graph. This removes them at the source instead of papering over them with a replace directive. `go build ./...`, `go vet ./...` and an OSV scan of the module all pass. The Netlify build script, netlify.toml and the redirect are unchanged.
There was a problem hiding this comment.
Pull request overview
This PR refactors the svelte-netlify recipe to remove the archived aws-lambda-go-api-proxy dependency (and the local Fiber adapter built on top of it) by switching the Lambda entrypoint to github.com/carlmjohnson/gateway, leveraging Fiber v3’s adaptor to expose the app as an http.Handler.
Changes:
- Replace the custom Lambda handler/adapter approach with
gateway.ListenAndServe(..., adaptor.FiberApp(app)). - Remove the local
adapter/package and drop the archived proxy library from the module graph. - Update
go.mod/go.sumand docs to reflect the new structure/dependencies.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| svelte-netlify/cmd/gateway/main.go | Switch Lambda entrypoint to gateway + Fiber v3 adaptor |
| svelte-netlify/adapter/adapter.go | Remove custom adapter (no longer needed) |
| svelte-netlify/go.mod | Drop archived dependency; add gateway; tidy direct/indirect deps |
| svelte-netlify/go.sum | Remove archived dependency sums and associated transitive noise |
| svelte-netlify/README.md | Update project structure docs to remove adapter/ |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📝 WalkthroughWalkthroughThe PR removes the Fiber-to-AWS Lambda adapter and Lambda handler. The gateway now serves the existing Fiber routes through ChangesGateway runtime migration
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The comment said the host argument is unused on Lambda, which is imprecise. It is never parsed as a listen address, but it is used as a fallback Host for the constructed request when the API Gateway event does not carry one.
Companion to #5303, which removes the other user of the archived library.
github.com/awslabs/aws-lambda-go-api-proxywas archived on 21 May 2025. This recipe used itscorepackage through a local 109-line Fiber v3 adapter, since the library's own Fiber adapter only ever supported Fiber v2.Why not Lambda Web Adapter
The official successor is Lambda Web Adapter, which is the right answer for
aws-sam-container. It is not an option here: it ships as a Lambda layer (AWS_LAMBDA_EXEC_WRAPPER=/opt/bootstrap) or a container extension (/opt/extensions/lambda-adapter), and Netlify Functions support neither.github.com/carlmjohnson/gatewayis a maintained drop-in forhttp.ListenAndServeon Lambda. It decodes the sameevents.APIGatewayProxyRequestpayload Netlify delivers, so it fits without changing the deployment model at all.What changed
Fiber v3 already exposes an app as an
http.Handlerviamiddleware/adaptor, so the localadapterpackage is no longer needed and is removed.main.godrops from aninit/Handler/lambda.Startarrangement to a single call:build.sh,netlify.tomland the/api/*redirect are untouched.Note on that first argument, since it reads oddly and was raised in review: despite the function name it is not a listen address and is never parsed as one. It is only used as a fallback
Hostfor the constructed request when the event does not carry one."n/a"is the value from the library's own README example.Side effect: the module-graph noise is gone
The archived library bundled adapters for gin, chi, fiber v2, gorilla/mux, iris, echo and negroni in a single
go.mod, so importing any part of it pulled the entire framework list into the consumer's module graph.go list -mno longer knows any of these:github.com/awslabs/aws-lambda-go-api-proxygithub.com/gofiber/fiber/v22.52.1github.com/gomarkdown/markdowngithub.com/go-chi/chi/v55.0.8github.com/sirupsen/logrus1.8.1None of them were ever compiled into the binary, no
go.sumentries andgo mod whyreportedmain module does not need modulefor each, but they were reported by anything resolving the module graph rather than the build list. This removes them at the source rather than papering over them with areplacedirective, which is what #5300 attempted before being closed.Verification
go build ./...passesgo vet ./...passesgo list -mconfirms all five modules above are goneNot verified: an actual Netlify deploy, which needs an account and a live build. The payload type
gatewaydecodes (events.APIGatewayProxyRequest) is the same one the previous code received, so the wire contract is unchanged.Unrelated, worth knowing
Netlify is deprecating Lambda compatibility mode:
So this recipe will eventually need porting to the modern Netlify Functions API regardless. That is a separate piece of work and out of scope here.
Summary by CodeRabbit