module Lamby module Debug extend self def on?(event) params = event['multiValueQueryStringParameters'] || event['queryStringParameters'] (development? || ENV['LAMBY_DEBUG']) && params && params['debug'] == '1' end def call(event, context, env) [ 200, { 'Content-Type' => 'text/html' }, [body(event, context, env)] ] end private def body(event, context, env) <<-HTML

Lamby Debug Response

Event

              #{JSON.pretty_generate(event)}
            

Rack Env

              #{JSON.pretty_generate(env)}
            

#{context.class.name}

#{CGI::escapeHTML(context.inspect)} HTML end def development? ENV.to_h .slice('RACK_ENV', 'RAILS_ENV') .values .any? { |v| v.to_s.casecmp('development').zero? } end end end