Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambda - using gateway 301 error #35

Open
felix0324324 opened this issue Sep 23, 2020 · 3 comments
Open

Lambda - using gateway 301 error #35

felix0324324 opened this issue Sep 23, 2020 · 3 comments

Comments

@felix0324324
Copy link

i had added follow sameple code, zip and upload to aws lambda
but its not work for me...
Any suggestion please?


螢幕截圖 2020-09-23 下午12 48 38

螢幕截圖 2020-09-23 下午12 48 53


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)
}

@felix0324324 felix0324324 changed the title Lambda - Lambda - using gateway 301 error Sep 23, 2020
@UnquietCode
Copy link

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
Copy link

KOSSOKO commented Mar 22, 2021

@felix0324324 did you find a solution ?

@tom-on-the-internet
Copy link

Same issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants