Comments (3)
Furthermore, the actual lambda function that you're passing through to needs set Access-Control-Allow-Origin to '*'.
A better implementation here would be one where:
- hookshot.passthrough creates a lambda function that is invoked by api-gateway
- that function receives all the data and handles CORS by directly answering OPTIONS requests
- if its not OPTIONS, the lambda function invokes the caller's function as RequestResponse
- wrapper lambda receives the payload, wraps it up in the right headers, and sends back the response to api-gateway
from deprecated-hookshot.
I've tinkered a little bit, trying to figure out how I might do this. I don't think I made very meaningful progress. Some questions:
- Lets call the new Lambda function
PassthroughLambda
. Would we wantPassthroughLambda
to be theIntegrationMethod
for bothOPTIONS
andPOST
methods? I'm not sure how I could insert a Lambda function intoIntegrationMethod
. Would I be able to set theUri
tocf.sub(
arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${PassthroughLambda.Arn}/invocations)
? - How can
PassthroughLambda
invoke the caller's Lambda function?
from deprecated-hookshot.
The PassthroughLambda
would be invoked by EVERY api-gateway method. If its an OPTIONS request, that lambda function would intelligently return CORS headers and would not even invoke the caller's lambda function. If it is any other type of request, it would forward the entire request payload to the hookshot caller's lambda function by using the aws-sdk to make a lambda.invoke()
AWS API call.
This invocation would be of the RequestResponse
type, which means lambda.invoke().promise()
will resolve with data that the caller's lambda intends to send as the api-gateway response. The PassthroughLambda
would get that data, slap on any needed CORS headers in, and respond to the original request.
from deprecated-hookshot.
Related Issues (12)
- Publish! HOT 1
- Use API key instead of creating an AWS IAM user HOT 1
- Access-Control-Allow-Headers not getting set in OPTIONS response with CORS
- Eng standards inventory HOT 1
- Archive this repository HOT 2
- Return full message from GitHub HOT 2
- Update readme to be general
- Can I access $context in my API? HOT 5
- CF template with multiple webhooks would have naming collisions HOT 1
- CORS option
- Replace AWS::ApiGateway::Deployment name on updates HOT 2
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 deprecated-hookshot.