-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to Name Handlers #70
Comments
With the request Mapping Template now transforming the Lambda events into Panda Request Representation, we now have access to the HTTP Method in the This opens up some new possibilities that I need to muse on. |
Consider this as a new approach to the Sky Lambda dispatcher: exports.handle = (request, context, callback) ->
resource = Blurb.getResource(context)
methodName = request.method
resource[methodName](request, context)
.then (result) ->
callback null, result
.catch (e) ->
callback e |
|
Currently in the CloudFormation template: BlurbGetLambdaHandler:
Type: 'AWS::Lambda::Function'
Properties:
Description: Handler for APIblurb9
FunctionName: blurb9-staging-blurb-get |
We could simplify by having one Lambda per resource, instead of per (resource X method). |
In API Gateway, we can determine the deployment environment using Mapping Template's |
Implication of the above two links is that we may be able use API Gateway stageVariables instead of putting stage names in our function names. |
semi-helpful discussion: https://forums.aws.amazon.com/thread.jspa?messageID=681736 |
I have not found any AWS native way to deal with the application namespacing (e.g. "blurb9") though. |
It's risky to jump straight into trusting all the AWS affordances I've just described. Here's an idea for the next safe step: exports.handle = (request, context, callback) ->
[_app, _stage, resource] = context.functionName.split('-')
resource = Blurb9.getResource(resource)
methodName = request.method
resource[methodName](request, context)
.then (result) ->
callback null, result
.catch (e) ->
callback e |
This moves us one---very important---step closer to isomorphism between the AWS concepts and the Sky API concepts. |
Blurb9 = Sky.API
resources:
Blurbs: require "./resources/blurbs"
Blurb: require "./resources/blurb" |
|
Yeah, in a variety of ways. My code example is just a riff on the current helper.
Because AWS has them as separate (confusing) arguments. In these examples, I'm trying to cleave close to our existing work and the AWS apis, to make it easier to see what's going on. |
Both "API Gateway Mapping Templates" and "Lambda handler functions" use the term |
With the |
Right now, we rely on a convention for Lambda names:
Sky assumes this pattern when it creates and names Lambdas, but that's not enforced in the actual code that constitutes Lambdas. So, within the code, we are relying on convention.
We should solidify our design and then enforce it, both in the CloudFormation template and the Lambda code.
The text was updated successfully, but these errors were encountered: