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

Example in the README doesn't work #22

Open
dorneanu opened this issue Aug 8, 2019 · 1 comment
Open

Example in the README doesn't work #22

dorneanu opened this issue Aug 8, 2019 · 1 comment

Comments

@dorneanu
Copy link

dorneanu commented Aug 8, 2019

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

@fleaz
Copy link
Contributor

fleaz commented Dec 2, 2019

Hey @dorneanu

take a look at #25 :)

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

2 participants