class Sidekiq::Web::Config

See ‘examples/webui-ext` for a sample web extension.
loaded in some processes (like an actual Sidekiq process).
does not belong in your initializer since Web should not be
This should go in your `config/routes.rb` or similar. It
end
config.register(MyExtension, name: “myext”, tab: “TabName”, index: “tabpage/”)
Sidekiq::Web.configure do |config|
require “sidekiq/web”
Configure the Sidekiq::Web instance in this process:
#

def initialize

def initialize
  @options = OPTIONS.dup
  @locales = LOCALES
  @views = VIEWS
  @tabs = DEFAULT_TABS.dup
  @middlewares = []
  @custom_job_info_rows = []
end

def register_extension(extclass, name:, tab:, index:, root_dir: nil, cache_for: 86400, asset_paths: nil)

Parameters:
  • cache_for (Integer) -- amount of time to cache assets, default one day
  • asset_paths (Array) -- one or more directories under {root}/assets/{name} to be publicly served, e.g. ["js", "css", "img"]
  • root_dir (String) -- directory location to find assets, locales and views, typically `web/` within the gemfile
  • index (String | Array) -- index route(s) for each tab
  • tab (String | Array) -- labels(s) of the UI tabs
  • name (String) -- the name of the extension, used to namespace assets
  • extclass (Class) -- Class which contains the HTTP actions, required
def register_extension(extclass, name:, tab:, index:, root_dir: nil, cache_for: 86400, asset_paths: nil)
  tab = Array(tab)
  index = Array(index)
  tab.zip(index).each do |tab, index|
    tabs[tab] = index
  end
  if root_dir
    locdir = File.join(root_dir, "locales")
    locales << locdir if File.directory?(locdir)
    if asset_paths && name
      # if you have {root}/assets/{name}/js/scripts.js
      # and {root}/assets/{name}/css/styles.css
      # you would pass in:
      #   asset_paths: ["js", "css"]
      # See script_tag and style_tag in web/helpers.rb
      assdir = File.join(root_dir, "assets")
      assurls = Array(asset_paths).map { |x| "/#{name}/#{x}" }
      assetprops = {
        urls: assurls,
        root: assdir,
        cascade: true
      }
      assetprops[:header_rules] = [[:all, {"cache-control" => "private, max-age=#{cache_for.to_i}"}]] if cache_for
      middlewares << [[Rack::Static, assetprops], nil]
    end
  end
  yield self if block_given?
  extclass.registered(Web::Application)
end

def use(*args, &block)

def use(*args, &block)
  middlewares << [args, block]
end