Skip to content
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

Docs on Advanced Usage & Configs #138

Open
metaskills opened this issue Dec 19, 2022 · 1 comment
Open

Docs on Advanced Usage & Configs #138

metaskills opened this issue Dec 19, 2022 · 1 comment

Comments

@metaskills
Copy link
Member

Now that we have Lamby v4, with various Rack handler and proc configs, we should document them all in one place. Will do this on the new site. Will also cover some DIY escape hatches if Lamby.cmd does not work for you.

require_relative 'config/environment'
$app = Rack::Builder.new { run Rails.application }.to_app
def handler(event:, context:)
  Lamby.handler $app, event, context, rack: :http
end
@metaskills
Copy link
Member Author

Demonstrate how stuff like this from an app.rb example file would look:

$app = Rack::Builder.new do
  map '/robots.txt' do
    response = File.read("public/deny.txt")
    run ->(_env) { [200, { 'Content-Type' => 'text/plain' }, [response]] }
  end
  map ENV['RAILS_RELATIVE_URL_ROOT'] do
    run Rails.application
  end
end.to_app
LambdaPunch.start_server!

def handler(event:, context:)
  Lamby.handler $app, event, context, rack: :http
ensure
  LambdaPunch.push { NewRelic::Agent.agent.flush_pipe_data }
  LambdaPunch.handled!(context)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant