module Sidekiq::Web::Router
def delete(path, &) = route(:delete, path, &)
def delete(path, &) = route(:delete, path, &)
def get(path, &) = route(:get, path, &)
def get(path, &) = route(:get, path, &)
def head(path, &) = route(:head, path, &)
def head(path, &) = route(:head, path, &)
def match(env)
def match(env) request_method = env["REQUEST_METHOD"].downcase.to_sym path_info = ::Rack::Utils.unescape_path env["PATH_INFO"] # There are servers which send an empty string when requesting the root. # These servers should be ashamed of themselves. path_info = "/" if path_info == "" route_cache[request_method].each do |route| params = route.match(request_method, path_info) if params env["rack.route_params"] = params return Action.new(env, route.block) end end nil end
def patch(path, &) = route(:patch, path, &)
def patch(path, &) = route(:patch, path, &)
def post(path, &) = route(:post, path, &)
def post(path, &) = route(:post, path, &)
def put(path, &) = route(:put, path, &)
def put(path, &) = route(:put, path, &)
def route(*methods, path, &block)
def route(*methods, path, &block) methods.each do |method| raise ArgumentError, "Invalid method #{method}. Must be one of #{@routes.keys.join(",")}" unless route_cache.has_key?(method) route_cache[method] << Route.new(method, path, block) end end
def route_cache
def route_cache @@routes ||= {get: [], post: [], put: [], patch: [], delete: [], head: []} end