Class: Wurk::Web
- Inherits:
-
Object
- Object
- Wurk::Web
- Defined in:
- lib/wurk/web.rb,
lib/wurk/web/config.rb,
lib/wurk/web/search.rb,
lib/wurk/web/helpers.rb,
lib/wurk/web/rack_app.rb,
lib/wurk/web/extension.rb,
lib/wurk/web/paginator.rb,
lib/wurk/web/enterprise.rb,
lib/wurk/web/pool_scope.rb,
lib/wurk/web/batch_status.rb,
lib/wurk/web/stats_routes.rb,
lib/wurk/web/locale_negotiator.rb
Overview
Web UI namespace. Holds three sibling concerns:
* `Wurk::Web::Config` + `Wurk::Web::Authorization` — the Rack-level
authorization hook (sidekiq-ent §9.2), 403 on falsey.
* `Wurk::Web::Search` — Pro substring search across queues/retries/
scheduled/dead (ZSCAN + glob; sidekiq-pro §10.1).
* `Wurk::Web::Enterprise` — Limits / Periodic / Historical helpers
(sidekiq-ent §9.1) used by the JSON APIs.
Wurk ships every Pro/Ent web feature free. Loading this file is enough
to make Wurk::Web.configure available — no separate require needed.
The class body is intentionally empty — every concern lives in a sibling file already required above. Rubocop's Lint/EmptyClass is disabled because this is a namespace anchor, not a missing-implementation bug.
Defined Under Namespace
Modules: Enterprise, Extension, LocaleNegotiator, Paginator, PoolScope, StatsRoutes Classes: Authorization, BatchStatus, Config, MiddlewareStack, Search
Constant Summary collapse
- SAFE_METHODS =
Upstream-compatible class-level Rack surface (#204): Sidekiq apps do
run Sidekiq::Web,mount Sidekiq::Web => "/sidekiq", and rack-test ecosystem suites callSidekiq::Web.call(env)directly. This entry serves the machine-readable routes (StatsRoutes) and the registered third-party Web extensions (#187's renderer) under their own route paths. Everything else is the dashboard, which is the engine's: in a booted Rails app the request goes there, through the engine's own copy of the gates below, so the stock install line shows the dashboard. Without an engine those paths 404 rather than half-serve the SPA.Same CSRF model as upstream Sidekiq 8 and ExtensionsController (spec §25.1): unsafe methods must carry
Sec-Fetch-Site: same-origin. %w[GET HEAD OPTIONS TRACE].freeze
- NOT_FOUND_HEADERS =
{ 'Content-Type' => 'text/plain' }.freeze
- NO_ENGINE_FIX =
'Wurk serves its dashboard from its Rails engine, so this Rack app answers only ' \ 'routes of registered Web extensions. Mount Sidekiq::Web or Wurk::Engine in a ' \ 'Rails app to get the dashboard.'
Class Method Summary collapse
- .app_url ⇒ Object
- .app_url=(value) ⇒ Object
- .assets_path ⇒ Object
- .assets_path=(value) ⇒ Object
-
.call(env) ⇒ Object
Class-level Rack entry: host middleware (
Wurk::Web.use), then the sameauthorization+ read-only gate the engine mount runs, then the extensions dispatcher. - .config ⇒ Object
-
.configure ⇒ Object
With a block: yields the config (the documented configure form).
- .custom_job_info_rows ⇒ Object
- .locales ⇒ Object
- .middlewares ⇒ Object
-
.register(extension) ⇒ Object
(also: register_extension)
Class-level extension surface — gems call these straight off
Sidekiq::Web(e.g.Sidekiq::Web.register(Ext, name:, tab:)orSidekiq::Web.tabs["Locks"] = "locks"), not only insideconfigure. -
.reset_config! ⇒ Object
Test helper — exposed for parity with
Wurk::Limiter.reset_config!. - .tabs ⇒ Object
-
.use ⇒ Object
Class-level shorthand for
config.use— mirrorsSidekiq::Web.use. - .views ⇒ Object
Class Method Details
.app_url ⇒ Object
439 440 441 |
# File 'lib/wurk/web/config.rb', line 439 def app_url config.app_url end |
.app_url=(value) ⇒ Object
443 444 445 |
# File 'lib/wurk/web/config.rb', line 443 def app_url=(value) config.app_url = value end |
.assets_path ⇒ Object
447 448 449 |
# File 'lib/wurk/web/config.rb', line 447 def assets_path config.assets_path end |
.assets_path=(value) ⇒ Object
451 452 453 |
# File 'lib/wurk/web/config.rb', line 451 def assets_path=(value) config.assets_path = value end |
.call(env) ⇒ Object
Class-level Rack entry: host middleware (Wurk::Web.use), then the
same authorization + read-only gate the engine mount runs, then the
extensions dispatcher. Sidekiq Enterprise gates mount Sidekiq::Web
with exactly these, and Wurk ships Ent, so an app that swapped the gem
keeps its authorization on this mount too.
33 34 35 36 37 |
# File 'lib/wurk/web/rack_app.rb', line 33 def call(env) return ::Wurk::Engine.call(env) if engine_page?(env) PoolScope.scope { config.rack_app(standalone_app).call(env) } end |
.config ⇒ Object
395 396 397 |
# File 'lib/wurk/web/config.rb', line 395 def config @config ||= Config.new end |
.configure ⇒ Object
With a block: yields the config (the documented configure form).
Without: returns it — upstream's blockless-getter form, which gems
use as Sidekiq::Web.configure.tabs (#204).
402 403 404 |
# File 'lib/wurk/web/config.rb', line 402 def configure block_given? ? yield(config) : config end |
.custom_job_info_rows ⇒ Object
435 436 437 |
# File 'lib/wurk/web/config.rb', line 435 def custom_job_info_rows config.custom_job_info_rows end |
.locales ⇒ Object
423 424 425 |
# File 'lib/wurk/web/config.rb', line 423 def locales config.locales end |
.middlewares ⇒ Object
431 432 433 |
# File 'lib/wurk/web/config.rb', line 431 def middlewares config.middlewares end |
.register(extension) ⇒ Object Also known as: register_extension
Class-level extension surface — gems call these straight off
Sidekiq::Web (e.g. Sidekiq::Web.register(Ext, name:, tab:) or
Sidekiq::Web.tabs["Locks"] = "locks"), not only inside configure.
414 415 416 |
# File 'lib/wurk/web/config.rb', line 414 def register(extension, **, &) config.register_extension(extension, **, &) end |
.reset_config! ⇒ Object
Test helper — exposed for parity with Wurk::Limiter.reset_config!.
Production callers should not need to drop the auth block at runtime.
457 458 459 |
# File 'lib/wurk/web/config.rb', line 457 def reset_config! @config = nil end |
.tabs ⇒ Object
419 420 421 |
# File 'lib/wurk/web/config.rb', line 419 def tabs config.tabs end |
.use ⇒ Object
Class-level shorthand for config.use — mirrors Sidekiq::Web.use.
407 408 409 |
# File 'lib/wurk/web/config.rb', line 407 def use(...) config.use(...) end |
.views ⇒ Object
427 428 429 |
# File 'lib/wurk/web/config.rb', line 427 def views config.views end |