Sha256: ec6e04bd5d36edbd658485cc89dc7842aa07d6ca50b64713d7b3a355c8120d10

Contents?: true

Size: 893 Bytes

Versions: 14

Compression:

Stored size: 893 Bytes

Contents

require "bundler/setup"
require "jets"
Jets.once  # runs once in lambda execution context

def lambda_handler(event:, context:)
  if event['_prewarm']
    Jets.process(event, context, nil)
    return
  end

<% if @vars.process_type == "controller" -%>
  route = Jets::Router.find_route_by_event(event)
  controller = route.controller_name
  action = route.action_name
  if Jets.config.cfn.build.routes == "one_apigw_method_for_all_routes"
    event["pathParameters"] = route.rebuild_path_parameters(event) # override
  end
<% end -%>
  Jets.process(event, context, "handlers/controllers/#{controller}.#{action}")
end
<% if ENV['JETS_DEBUG_HANDLER'] %>
<%# JETS_DEBUG_HANDLER=1 jets build %>
if __FILE__ == $0
  event = {
    "path" => "/posts",
    "httpMethod" => "GET",
    "headers" => {
      "Host" => "localhost:8888",
    }
  }
  lambda_handler(event: event, context: {})
end
<% end %>

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
jets-5.0.13 lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb
jets-5.0.12 lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb
jets-5.0.11 lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb
jets-5.0.10 lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb
jets-5.0.9 lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb
jets-5.0.8 lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb
jets-5.0.7 lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb
jets-5.0.6 lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb
jets-5.0.5 lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb
jets-5.0.4 lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb
jets-5.0.3 lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb
jets-5.0.2 lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb
jets-5.0.1 lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb
jets-5.0.0 lib/jets/builders/templates/handlers/one_lambda_for_all_controllers.rb