Giter Club home page Giter Club logo

Comments (7)

hilyjiang avatar hilyjiang commented on August 28, 2024 1

Yes, the query strings work normal.

Request: /user?email=[email protected]
Response Body:

{
  "HTTPMethod": "GET",
  "Headers": null,
  "Resource": "/user",
  "PathParameters": null,
  "Path": "/user",
  "QueryStringParameters": {
    "email": "[email protected]"
  },
  "Body": "",
  "IsBase64Encoded": false,
  "StageVariables": null,
  "RequestContext": {
    "APIID": "za4usr3af8",
    "ResourceID": "iy0ic1",
    "RequestID": "test-invoke-request",
    "HTTPMethod": "GET",
    "ResourcePath": "/user",
    "AccountID": "072791703432",
    "Stage": "test-invoke-stage",
    "Identity": {
    ...hide...
    },
    "Authorizer": null
  }
}

from archive_aws-lambda-go-event.

fsenart avatar fsenart commented on August 28, 2024

Hi @sateeshyandapalli,
Can you please provide a minimal example of how you've configured your API Gateway (a cloudformation template or so). And please take a look at https://github.com/eawsy/aws-lambda-go-net
(along with its deployment template) which uses the API Gateway proxy event successfully.

from archive_aws-lambda-go-event.

hilyjiang avatar hilyjiang commented on August 28, 2024

The example code doesn't work for me (would cause 502 gateway error).

But the code following works for me, you can have a try. @sateeshyandapalli

package main

import (
	"encoding/json"

	"github.com/eawsy/aws-lambda-go-core/service/lambda/runtime"
	"github.com/eawsy/aws-lambda-go-event/service/lambda/runtime/event/apigatewayproxyevt"
)

func Handle(evt *apigatewayproxyevt.Event, ctx *runtime.Context) (interface{}, error) {
	buf, err := json.Marshal(evt)
	if err != nil {
		return nil, err
	}

	return map[string]interface{}{
		"statusCode": 200,
		"body":       string(buf),
	}, nil
}

from archive_aws-lambda-go-event.

fsenart avatar fsenart commented on August 28, 2024

Hi @hilyjiang,
Can you please provide more details about what is not working. Do you talk about the go-net examples? Which one?

from archive_aws-lambda-go-event.

hilyjiang avatar hilyjiang commented on August 28, 2024

@fsenart

I try to create a API with Lambda Proxy Itergration, using the code from:
https://github.com/eawsy/aws-lambda-go-event/tree/master/service/lambda/runtime/event/apigatewayproxyevt

package main

import (
	"log"

	"github.com/eawsy/aws-lambda-go-event/service/lambda/runtime/event/apigatewayproxyevt"
	"github.com/eawsy/aws-lambda-go-core/service/lambda/runtime"
)

func Handle(evt *apigatewayproxyevt.Event, ctx *runtime.Context) (interface{}, error) {
	log.Println(evt)
	return nil, nil
}

But the output format of Handle didn't match the format mentioned in:
https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-set-up-simple-proxy.html

So I modified it to the code in the above post, and it works.

from archive_aws-lambda-go-event.

fsenart avatar fsenart commented on August 28, 2024

@hilyjiang you're right in the fact that the provided example won't work behind api gateway proxy mode. But notice that all provided examples (other events included) are only here to show the "shape" of the incoming event and mostly work when using the AWS Lambda console test events. Otherwise we have to provide for each event the exact way it will integrate with each service in different contexts, etc.
And that's why complex events like API Gateway Proxy have their own projects like https://github.com/eawsy/aws-lambda-go-net to provide real usability.

from archive_aws-lambda-go-event.

fsenart avatar fsenart commented on August 28, 2024

BTW, you confirm that when using your snippet you have access to query strings? So I can close this issue for now as I haven't feedback from @sateeshyandapalli.

from archive_aws-lambda-go-event.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.