From 288db953e440157423d215260b24c94f22c292f6 Mon Sep 17 00:00:00 2001 From: Amadeus Folego Date: Sat, 30 Jul 2016 11:12:08 -0300 Subject: [PATCH] Add Sidekiq::Web.use --- lib/sidekiq/web.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/sidekiq/web.rb b/lib/sidekiq/web.rb index 46c4f7b1..b4cc5394 100644 --- a/lib/sidekiq/web.rb +++ b/lib/sidekiq/web.rb @@ -38,6 +38,14 @@ module Sidekiq self end + def middlewares + @middlewares ||= [] + end + + def use(*middleware_args, &block) + middlewares << [middleware_args, block] + end + def default_tabs DEFAULT_TABS end @@ -85,6 +93,8 @@ module Sidekiq use ::Rack::Session::Cookie, secret: secret use ::Rack::Protection, use: :authenticity_token unless ENV['RACK_ENV'] == 'test' + Web.middlewares.each {|middleware, block| use *middleware, &block } + run WebApplication.new(klass) end end