class Sidekiq::Web::Application
def self.helpers(mod)
method naming as there's no namespacing so collisions are
any defined endpoints in Application. Careful with generic
Used by extensions to add helper methods accessible to
def self.helpers(mod) Sidekiq::Web::Action.send(:include, mod) end
def call(env)
def call(env) action = match(env) return [404, {"content-type" => "text/plain", "x-cascade" => "pass"}, ["Not Found"]] unless action headers = { "content-type" => "text/html", "cache-control" => "private, no-store", "content-language" => action.locale, "content-security-policy" => process_csp(env, CSP_HEADER_TEMPLATE), "x-content-type-options" => "nosniff" } env["response_headers"] = headers resp = catch(:halt) do Thread.current[:sidekiq_redis_pool] = env[:redis_pool] action.instance_exec env, &action.block ensure Thread.current[:sidekiq_redis_pool] = nil end case resp when Array # redirects go here resp else # rendered content goes here # we'll let Rack calculate Content-Length for us. [200, env["response_headers"], [resp]] end end
def initialize(inst)
def initialize(inst) @app = inst end
def process_csp(env, input)
def process_csp(env, input) input.gsub("!placeholder!", env[:csp_nonce]) end
def redis(&)
def redis(&) Thread.current[:sidekiq_redis_pool].with(&) end