Example in the README doesn't work
Opened this issue · 1 comments
dorneanu commented
Hi,
I'm trying to get apex/gateway
to work, however the provided example doesn't really work:
apex ᐅ export GO111MODULE=on
apex ᐅ cat main.go
package main
import (
"fmt"
"log"
"net/http"
"github.com/apex/gateway"
"github.com/aws/aws-lambda-go"
)
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)
}
apex ᐅ go build main.go
go: finding github.com/aws/aws-lambda-go/events latest
go: finding github.com/aws/aws-lambda-go/lambda latest
build command-line-arguments: cannot load github.com/aws/aws-lambda-go: cannot find module providing package github.com/aws/aws-lambda-go
Any ideas? Thanks in advance.
BR,
Victor