module AwsLambdaRuntime
Overview
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 
Defined in:
aws_lambda_runtime.craws_lambda_runtime/client.cr
aws_lambda_runtime/invocation.cr
aws_lambda_runtime/lambda_context.cr
Constant Summary
- 
        VERSION = 
"0.2.2" 
Class Method Summary
- 
        .run(&block : JSON::Any, Invocation -> T) forall T
        
          
Permits the runtime to be invoked with a block, parses the event.
 - 
        .run(handler : Proc(JSON::Any, Invocation, T)) forall T
        
          
Permits the runtime to be passed a handler as a proc, parses the event.
 - 
        .run(handler : Proc(String, Invocation, T)) forall T
        
          
Permits the runtime to be passed a handler as a proc, does not parse the event.
 
Class Method Detail
        
        def self.run(&block : JSON::Any, Invocation -> T) forall T
        #
      
      
        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
        
        
        def self.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))
        
        
        def self.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))