Module: Rack::Shelf

Extended by:
Shelf
Included in:
Shelf
Defined in:
lib/rack/shelf.rb,
lib/rack/shelf/version.rb,
lib/rack/shelf/api_gateway.rb,
lib/rack/shelf/response_adapter.rb,
lib/rack/shelf/environment_builder.rb,
lib/rack/shelf/base64_response_adapter.rb

Overview

Adapts AWS Lambda event sources to Rack environments.

Defined Under Namespace

Classes: APIGateway, Base64ResponseAdapter, EnvironmentBuilder, ResponseAdapter

Constant Summary collapse

VERSION =
'0.0.1'

Instance Method Summary collapse

Instance Method Details

#api_gateway(app, event, context) ⇒ Hash

Runs a Rack application, translating the request and response. This method assumes the Lambda event came from API Gateway.

Parameters:

  • app (#call)

    Rack application to call.

  • event (Hash)

    Lambda event hash.

  • context (Object)

    Lambda context object.

Returns:

  • (Hash)

    AWS Lambda response.



20
21
22
# File 'lib/rack/shelf.rb', line 20

def api_gateway(app, event, context)
  run(APIGateway, ResponseAdapter, app, event, context)
end

#api_gateway_base64(app, event, context) ⇒ Hash

Runs a Rack application, translating the request and response. This method assumes the Lambda event came from API Gateway. The response body is encoded as base-64.

Parameters:

  • app (#call)

    Rack application to call.

  • event (Hash)

    Lambda event hash.

  • context (Object)

    Lambda context object.

Returns:

  • (Hash)

    AWS Lambda response.



31
32
33
# File 'lib/rack/shelf.rb', line 31

def api_gateway_base64(app, event, context)
  run(APIGateway, Base64ResponseAdapter, app, event, context)
end