lib/sidekiq/web/application.rb in sidekiq-4.2.2 vs lib/sidekiq/web/application.rb in sidekiq-4.2.3
- old
+ new
@@ -5,11 +5,10 @@
extend WebRouter
CONTENT_LENGTH = "Content-Length".freeze
CONTENT_TYPE = "Content-Type".freeze
REDIS_KEYS = %w(redis_version uptime_in_days connected_clients used_memory_human used_memory_peak_human)
- NOT_FOUND = [404, {"Content-Type" => "text/plain", "X-Cascade" => "pass" }.freeze, ["Not Found"]]
def initialize(klass)
@klass = klass
end
@@ -26,11 +25,11 @@
end
def self.set(key, val)
# nothing, backwards compatibility
end
-
+
get "" do
redirect(root_path)
end
get "/" do
@@ -260,11 +259,11 @@
json Sidekiq::Stats::Queues.new.lengths
end
def call(env)
action = self.class.match(env)
- return NOT_FOUND unless action
+ return [404, {"Content-Type" => "text/plain", "X-Cascade" => "pass" }, ["Not Found"]] unless action
resp = catch(:halt) do
app = @klass
self.class.run_befores(app, action)
begin
@@ -282,14 +281,14 @@
when Fixnum
[resp, {}, []]
else
type_header = case action.type
when :json
- WebAction::APPLICATION_JSON
+ { "Content-Type" => "application/json", "Cache-Control" => "no-cache" }
when String
- { WebAction::CONTENT_TYPE => action.type, "Cache-Control" => "no-cache" }
+ { "Content-Type" => action.type, "Cache-Control" => "no-cache" }
else
- WebAction::TEXT_HTML
+ { "Content-Type" => "text/html", "Cache-Control" => "no-cache" }
end
[200, type_header, [resp]]
end