class Sidekiq::WebApplication
Constants
- CSP_HEADER
- QUEUE_NAME
- REDIS_KEYS
Public Class Methods
after(path = nil, &block)
click to toggle source
# File lib/sidekiq/web/application.rb, line 357 def self.after(path = nil, &block) afters << [path && Regexp.new("\\A#{path.gsub("*", ".*")}\\z"), block] end
afters()
click to toggle source
# File lib/sidekiq/web/application.rb, line 378 def self.afters @afters ||= [] end
before(path = nil, &block)
click to toggle source
# File lib/sidekiq/web/application.rb, line 353 def self.before(path = nil, &block) befores << [path && Regexp.new("\\A#{path.gsub("*", ".*")}\\z"), block] end
befores()
click to toggle source
# File lib/sidekiq/web/application.rb, line 374 def self.befores @befores ||= [] end
helpers(mod = nil, &block)
click to toggle source
# File lib/sidekiq/web/application.rb, line 345 def self.helpers(mod = nil, &block) if block WebAction.class_eval(&block) else WebAction.send(:include, mod) end end
new(klass)
click to toggle source
# File lib/sidekiq/web/application.rb, line 24 def initialize(klass) @klass = klass end
run_afters(app, action)
click to toggle source
# File lib/sidekiq/web/application.rb, line 365 def self.run_afters(app, action) run_hooks(afters, app, action) end
run_befores(app, action)
click to toggle source
# File lib/sidekiq/web/application.rb, line 361 def self.run_befores(app, action) run_hooks(befores, app, action) end
run_hooks(hooks, app, action)
click to toggle source
# File lib/sidekiq/web/application.rb, line 369 def self.run_hooks(hooks, app, action) hooks.select { |p, _| !p || p =~ action.env[WebRouter::PATH_INFO] } .each { |_, b| action.instance_exec(action.env, app, &b) } end
set(key, val)
click to toggle source
# File lib/sidekiq/web/application.rb, line 40 def self.set(key, val) # nothing, backwards compatibility end
settings()
click to toggle source
# File lib/sidekiq/web/application.rb, line 32 def self.settings Sidekiq::Web.settings end
tabs()
click to toggle source
# File lib/sidekiq/web/application.rb, line 36 def self.tabs Sidekiq::Web.tabs end
Public Instance Methods
call(env)
click to toggle source
# File lib/sidekiq/web/application.rb, line 316 def call(env) action = self.class.match(env) return [404, {"content-type" => "text/plain", "x-cascade" => "pass"}, ["Not Found"]] unless action app = @klass resp = catch(:halt) do self.class.run_befores(app, action) action.instance_exec env, &action.block ensure self.class.run_afters(app, action) end case resp when Array # redirects go here resp else # rendered content goes here headers = { "content-type" => "text/html", "cache-control" => "private, no-store", "content-language" => action.locale, "content-security-policy" => CSP_HEADER } # we'll let Rack calculate Content-Length for us. [200, headers, [resp]] end end
settings()
click to toggle source
# File lib/sidekiq/web/application.rb, line 28 def settings @klass.settings end