Lambda - using gateway 301 error
Opened this issue · 3 comments
felix0324324 commented
i had added follow sameple code, zip and upload to aws lambda
but its not work for me...
Any suggestion please?
import (
"fmt"
"log"
"net/http"
"os"
"github.com/apex/gateway"
)
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)
}
UnquietCode commented
This is almost certainly a problem with mux. Try to pass your handler directly to gateway and see if that works. Mux has issues with slashes that seem to conflict with API gateway. You can also play with a default route in API gateway to see if that helps.
KOSSOKO commented
@felix0324324 did you find a solution ?
tom-on-the-internet commented
Same issue...