Module: Sidekiq::WebRouter
- Included in:
- WebApplication
- Defined in:
- lib/sidekiq/web/router.rb
Constant Summary collapse
- GET =
'GET'.freeze
- DELETE =
'DELETE'.freeze
- POST =
'POST'.freeze
- PUT =
'PUT'.freeze
- PATCH =
'PATCH'.freeze
- HEAD =
'HEAD'.freeze
- ROUTE_PARAMS =
'rack.route_params'.freeze
- REQUEST_METHOD =
'REQUEST_METHOD'.freeze
- PATH_INFO =
'PATH_INFO'.freeze
Instance Method Summary collapse
- #delete(path, &block) ⇒ Object
- #get(path, &block) ⇒ Object
- #match(env) ⇒ Object
- #patch(path, &block) ⇒ Object
- #post(path, &block) ⇒ Object
- #put(path, &block) ⇒ Object
- #route(method, path, &block) ⇒ Object
Instance Method Details
#delete(path, &block) ⇒ Object
33 34 35 |
# File 'lib/sidekiq/web/router.rb', line 33 def delete(path, &block) route(DELETE, path, &block) end |
#get(path, &block) ⇒ Object
17 18 19 |
# File 'lib/sidekiq/web/router.rb', line 17 def get(path, &block) route(GET, path, &block) end |
#match(env) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/sidekiq/web/router.rb', line 44 def match(env) request_method = env[REQUEST_METHOD] path_info = ::Rack::Utils.unescape env[PATH_INFO] @routes[request_method].each do |route| if params = route.match(request_method, path_info) env[ROUTE_PARAMS] = params return WebAction.new(env, route.block) end end nil end |
#patch(path, &block) ⇒ Object
29 30 31 |
# File 'lib/sidekiq/web/router.rb', line 29 def patch(path, &block) route(PATCH, path, &block) end |
#post(path, &block) ⇒ Object
21 22 23 |
# File 'lib/sidekiq/web/router.rb', line 21 def post(path, &block) route(POST, path, &block) end |
#put(path, &block) ⇒ Object
25 26 27 |
# File 'lib/sidekiq/web/router.rb', line 25 def put(path, &block) route(PUT, path, &block) end |
#route(method, path, &block) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/sidekiq/web/router.rb', line 37 def route(method, path, &block) @routes ||= { GET => [], POST => [], PUT => [], PATCH => [], DELETE => [], HEAD => [] } @routes[method] << WebRoute.new(method, path, block) @routes[HEAD] << WebRoute.new(method, path, block) if method == GET end |