Comments (8)
it turns out it's because I did not use lambda proxy integration. My bad.
from aws-lambda-go.
Hi @kkesley I'm having the same issue after enabling lambda integration in my serverless.yml, because I need it for custom status codes (302). Could you please describe little more how you solved the problem?. Thank you!
from aws-lambda-go.
Hi @m1ch3lp3r3z TBH I made a mistake by not providing any details to my issue and I forgot about the issue I was having. Can you provide an example for your serverless.yml detail? I might still remember when I see your configuration.
from aws-lambda-go.
Hi @kkesley, thank you for your quick reply. I'm trying to implement a lambda function that will receive data from a contact us form (application/x-www-form-urlencoded) and will return a 302 status code and Location header. My handler definition in serverless.yml looks like:
functions:
contactUs:
handler: go/bin/handlers/contact_us
warmup:
enabled: false
events:
- http:
path: ${self:custom.apiVersion}/contact-us
method: post
cors: false
integration: lambda
response:
statusCodes:
302:
pattern: '' # Default response method
headers:
Content-Type: "'text/html'"
Location: integration.response.header.location
Since I added the lambda integration
I'm getting this error from the API Gateway:
{"errorMessage":"json: cannot unmarshal object into Go struct field APIGatewayProxyRequest.body of type string","errorType":"UnmarshalTypeError"}
The request is not even reaching my function so I'm guessing API Gateway is trying to parse the input as a JSON, but I fail to see where to change that.
Thank you!
from aws-lambda-go.
@m1ch3lp3r3z for me, I'm not using integration: lambda
and just send the response in the code.
return events.APIGatewayProxyResponse{
Body: "some string",
IsBase64Encoded: false,
Headers: map[string]string{
"Content-Type": "text/plain",
"Access-Control-Allow-Origin": "*",
},
StatusCode: 302,
}, nil
from aws-lambda-go.
@kkesley I actually started there, as soon as I set the StatusCode: 302
in my returned Response object I get "message": "Missing Authentication Token"
(403). I think API Gateway by default only allows success or error status codes (out of the lambda fn). Wondering if you don't have any other configuration related to the status code 302 in your serverless.yml
from aws-lambda-go.
@m1ch3lp3r3z Hmm... I didn't set the response
field in the serverless.yml
. Is it only happening for 302 status code or can you test another one? e.g. 202 or 400?
from aws-lambda-go.
Wow... the problem is the Location
header, If I remove it I get the 302 status code through, but then how to tell the browser where to redirect to?
FYI 202 Accepted
works good and probably 4XX too.
Thank you for the help!!
from aws-lambda-go.
Related Issues (20)
- Method with signature events.APIGatewayProxyRequest and events.APIGatewayProxyResponse doesn't invoke Http API
- Lambda Event to support Lex V2 API
- feat: Add support for AWS VPC Lattice events
- The generic handler is slower than the dynamic handler
- Support for `AWS_LAMBDA_EXEC_WRAPPER`
- S3ObjectLambdaEvent is missed in codebase
- events.CodeCommitReference has missing Deleted field HOT 2
- ALB target grouped Lambda returns fine but alb return 502 error that "LambdaInvalidResponse" HOT 2
- Deserialisation of array values in Cognito events custom UserAttributes not working correctly HOT 1
- Support structured JSON logging for errors HOT 2
- please add a mocked example HOT 1
- Custom runtime provided.al2 broken on v1.42 HOT 1
- Add IoTCoreMQTTMessage to aws/aws-lambda-go/events
- Add disconnectStatusCode to event/APIGatewayWebsocketProxyRequestContext
- RequestContext.Authorizer differs between REST gateway vs HTTP gateway
- UnmarshalTypeError on CodePipelineEventBridgeEvent HOT 3
- Missing field enableSMSMFA on struct events.CognitoEventUserPoolsMigrateUserResponse
- Runtime.InvalidEntrypoint
- Add AWS CloudWatch Alarm Event
- Implement `MultiValueHeaders` for ``events.LambdaFunctionURLResponse``
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-lambda-go.