AwsLambdaRuntime
An AWS Lambda runtime for crystal.
Installation
-
Add the dependency to your
shard.yml:dependencies: aws_lambda_runtime: github: lagr/aws_lambda_runtime -
Run
shards install
Constants
VERSION = "0.2.2"
Class methods
run
Permits the runtime to be invoked with a block, parses the event.
AwsLambdaRuntime.run do |event, invocation|
puts "event is a #{event.class.name}."
# => event is a JSON::Any.
{"serialize-this": "my friend"}
end
run(handler : Proc(JSON::Any, Invocation, T)) forall T
Permits the runtime to be passed a handler as a proc, parses the event.
def handler(event, invocation)
puts "event is a #{event.class.name}."
# => event is a JSON::Any.
{"serialize-this": "my friend"}
end
AwsLambdaRuntime.run(->handler(JSON::Any, AwsLambdaRuntime::Invocation))
run(handler : Proc(String, Invocation, T)) forall T
Permits the runtime to be passed a handler as a proc, does not parse the event.
This comes handy if the event context is not of interest or should be parsed in a more specialized manner.
def handler(event, invocation)
puts "event is a #{event.class.name}."
# => event is a String.
{"serialize-this": "my friend"}
end
AwsLambdaRuntime.run(->handler(String, AwsLambdaRuntime::Invocation))