module Lamby::Debug
Public Instance Methods
call(event, context, env)
click to toggle source
# File lib/lamby/debug.rb, line 12 def call(event, context, env) [ 200, { 'Content-Type' => 'text/html' }, [body(event, context, env)] ] end
on?(event)
click to toggle source
# File lib/lamby/debug.rb, line 7 def on?(event) params = event['multiValueQueryStringParameters'] || event['queryStringParameters'] (Rails.env.development? || ENV['LAMBY_DEBUG']) && params && params['debug'] == '1' end
Private Instance Methods
body(event, context, env)
click to toggle source
# File lib/lamby/debug.rb, line 18 def body(event, context, env) <<-HTML <!DOCTYPE html> <html> <body> <h1>Lamby Debug Response</h1> <h2>Event</h2> <pre> #{JSON.pretty_generate(event)} </pre> <h2>Rack Env</h2> <pre> #{JSON.pretty_generate(env)} </pre> <h2>#{context.class.name}</h2> <code> #{CGI::escapeHTML(context.inspect)} </code> <h2>Environment</h2> <pre> #{sam_local? ? JSON.pretty_generate(ENV.to_h) : 'N/A'} </pre> </body> </html> HTML end