Hi!
I’m trying to refactor a golang lambda I’m currently running in production to use akrylysov/algnhsa to be able to test more easily, since it is not possible to run go lambdas in Netlify Dev yet.
algnhsa
is overall working but I’m having issues setting headers. To replicate, deploy this function to both, Netlify Functions and AWS Lambda + API Gateway and curl
it:
package main
import (
"net/http"
"github.com/akrylysov/algnhsa"
)
func handler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("location", "https://en.wikipedia.org")
w.WriteHeader(http.StatusMovedPermanently)
}
func main() {
http.HandleFunc("/", handler)
algnhsa.ListenAndServe(http.DefaultServeMux, nil)
}
You will notice the location header is there for the AWS Lamda but it is not for the Netlify Function.
I’ve deployed the very same code above to both for you to test:
https://vigorous-galileo-f758df.netlify.com/.netlify/functions/test
https://iopemvdzz4.execute-api.us-east-1.amazonaws.com/default/
To clarify, if I use the regular lambda handler signature that takes events.APIGatewayProxyRequest
and returns an events.APIGatewayProxyResponse
, it does work (it is what I have in production right now). Adding algnhsa
as a compat layer works on AWS Lambda but strips the location
header in Netlify Functions.
So it makes me think there’s some other layer in Netlify Functions that might be out of sync with the AWS interface .