golang / dep

Go dependency management tool experiment (deprecated)
https://golang.github.io/dep/
BSD 3-Clause "New" or "Revised" License
12.87k stars 1.05k forks source link

aws-go-dep How To Get Params? #2222

Closed JimLynchCodes closed 4 years ago

JimLynchCodes commented 4 years ago

Hi, I just scaffolded the "aws-go-dep" serverless project, but I'm wondering how to access route params and query params.

In the code I have access to the context and response objects:

func Handler(ctx context.Context) (Response, error) {

But when I try to log the context it just looks like this:

Printing the ctx  context.Background.WithDeadline(2019-12-11 00:46:20.604 +0000 UTC [4m59.9622605s]).WithValue(type *lambdacontext.key, val <not Stringer>).WithValue(type string, val Root=1-dc99d00f-c079a84d433534434534ef0d;Parent=91ed514f1e5c03b2;Sampled=1)

If my url is https://mycoolurl/ImaRouteParam?queryParam=foo

how can I access the route param and query param?

Thanks!

JimLynchCodes commented 4 years ago

I was able to get the params like this:

type Response events.APIGatewayProxyResponse

// Handler is our lambda handler invoked by the `lambda.Start` function call
func Handler(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
    fmt.Printf("request %+v", request)
    fmt.Printf("request Body %+v", request.Body)
    fmt.Printf("request HTTPMethod %+v", request.HTTPMethod)
    fmt.Printf("request fancyHeader %+v", request.Headers["fancyHeader"])
    fmt.Printf("request QueryStringParameters %+v", request.QueryStringParameters)
    fmt.Printf("request PathParameters %+v", request.PathParameters)
...