apex / apex/gateway

Example in the README doesn't work

Open
#22 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
651
Forks
75
PR merge metrics
No merged PRs in 30d

Description

Hi,

I'm trying to get `apex/gateway` to work, however the provided example doesn't really work:

```.bash
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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.