Module: ActionDispatch::Routing::Mapper::HttpHelpers
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | actionpack/lib/action_dispatch/routing/mapper.rb |
Instance Method Summary
-
#connect(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: false, format: false, path: nil, internal: nil, **mapping, &block)
Define a route that recognizes HTTP CONNECT (and GET) requests.
-
#delete(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block)
Define a route that only recognizes HTTP DELETE.
-
#get(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block)
Define a route that only recognizes HTTP GET.
-
#options(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: false, format: false, path: nil, internal: nil, **mapping, &block)
Define a route that only recognizes HTTP OPTIONS.
-
#patch(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block)
Define a route that only recognizes HTTP PATCH.
-
#post(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block)
Define a route that only recognizes HTTP POST.
-
#put(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block)
Define a route that only recognizes HTTP PUT.
Instance Method Details
#connect(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: false, format: false, path: nil, internal: nil, **mapping, &block)
Define a route that recognizes HTTP CONNECT (and GET) requests. More specifically this recognizes HTTP/1 protocol upgrade requests and HTTP/2 CONNECT requests with the protocol pseudo header. For supported arguments, see [match](Base#match)
connect 'live', to: 'live#index'
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 889
def connect(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: false, format: false, path: nil, internal: nil, **mapping, &block) if path_or_actions.grep(Hash).any? && ( = path_or_actions. ) as = assign_deprecated_option(, :as, :connect) if .key?(:as) to ||= assign_deprecated_option(, :to, :connect) controller ||= assign_deprecated_option(, :controller, :connect) action ||= assign_deprecated_option(, :action, :connect) on ||= assign_deprecated_option(, :on, :connect) defaults ||= assign_deprecated_option(, :defaults, :connect) constraints ||= assign_deprecated_option(, :constraints, :connect) anchor = assign_deprecated_option(, :anchor, :connect) if .key?(:anchor) format = assign_deprecated_option(, :format, :connect) if .key?(:format) path ||= assign_deprecated_option(, :path, :connect) internal ||= assign_deprecated_option(, :internal, :connect) (, mapping, :connect) end match(*path_or_actions, as:, to:, controller:, action:, on:, defaults:, constraints:, anchor:, format:, path:, internal:, **mapping, via: [:get, :connect], &block) self end
#delete(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block)
Define a route that only recognizes HTTP DELETE. For supported arguments, see [match](Base#match)
delete 'broccoli', to: 'food#broccoli'
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 839
def delete(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block) if path_or_actions.grep(Hash).any? && ( = path_or_actions. ) as = assign_deprecated_option(, :as, :delete) if .key?(:as) to ||= assign_deprecated_option(, :to, :delete) controller ||= assign_deprecated_option(, :controller, :delete) action ||= assign_deprecated_option(, :action, :delete) on ||= assign_deprecated_option(, :on, :delete) defaults ||= assign_deprecated_option(, :defaults, :delete) constraints ||= assign_deprecated_option(, :constraints, :delete) anchor = assign_deprecated_option(, :anchor, :delete) if .key?(:anchor) format = assign_deprecated_option(, :format, :delete) if .key?(:format) path ||= assign_deprecated_option(, :path, :delete) internal ||= assign_deprecated_option(, :internal, :delete) (, mapping, :delete) end match(*path_or_actions, as:, to:, controller:, action:, on:, defaults:, constraints:, anchor:, format:, path:, internal:, **mapping, via: :delete, &block) self end
#get(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block)
Define a route that only recognizes HTTP GET. For supported arguments, see [match](Base#match)
get 'bacon', to: 'food#bacon'
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 743
def get(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block) if path_or_actions.grep(Hash).any? && ( = path_or_actions. ) as = assign_deprecated_option(, :as, :get) if .key?(:as) to ||= assign_deprecated_option(, :to, :get) controller ||= assign_deprecated_option(, :controller, :get) action ||= assign_deprecated_option(, :action, :get) on ||= assign_deprecated_option(, :on, :get) defaults ||= assign_deprecated_option(, :defaults, :get) constraints ||= assign_deprecated_option(, :constraints, :get) anchor = assign_deprecated_option(, :anchor, :get) if .key?(:anchor) format = assign_deprecated_option(, :format, :get) if .key?(:format) path ||= assign_deprecated_option(, :path, :get) internal ||= assign_deprecated_option(, :internal, :get) (, mapping, :get) end match(*path_or_actions, as:, to:, controller:, action:, on:, defaults:, constraints:, anchor:, format:, path:, internal:, **mapping, via: :get, &block) self end
#options(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: false, format: false, path: nil, internal: nil, **mapping, &block)
Define a route that only recognizes HTTP OPTIONS. For supported arguments, see [match](Base#match)
'carrots', to: 'food#carrots'
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 863
def (*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: false, format: false, path: nil, internal: nil, **mapping, &block) if path_or_actions.grep(Hash).any? && ( = path_or_actions. ) as = assign_deprecated_option(, :as, : ) if .key?(:as) to ||= assign_deprecated_option(, :to, : ) controller ||= assign_deprecated_option(, :controller, : ) action ||= assign_deprecated_option(, :action, : ) on ||= assign_deprecated_option(, :on, : ) defaults ||= assign_deprecated_option(, :defaults, : ) constraints ||= assign_deprecated_option(, :constraints, : ) anchor = assign_deprecated_option(, :anchor, : ) if .key?(:anchor) format = assign_deprecated_option(, :format, : ) if .key?(:format) path ||= assign_deprecated_option(, :path, : ) internal ||= assign_deprecated_option(, :internal, : ) (, mapping, : ) end match(*path_or_actions, as:, to:, controller:, action:, on:, defaults:, constraints:, anchor:, format:, path:, internal:, **mapping, via: :, &block) self end
#patch(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block)
Define a route that only recognizes HTTP PATCH. For supported arguments, see [match](Base#match)
patch 'bacon', to: 'food#bacon'
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 791
def patch(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block) if path_or_actions.grep(Hash).any? && ( = path_or_actions. ) as = assign_deprecated_option(, :as, :patch) if .key?(:as) to ||= assign_deprecated_option(, :to, :patch) controller ||= assign_deprecated_option(, :controller, :patch) action ||= assign_deprecated_option(, :action, :patch) on ||= assign_deprecated_option(, :on, :patch) defaults ||= assign_deprecated_option(, :defaults, :patch) constraints ||= assign_deprecated_option(, :constraints, :patch) anchor = assign_deprecated_option(, :anchor, :patch) if .key?(:anchor) format = assign_deprecated_option(, :format, :patch) if .key?(:format) path ||= assign_deprecated_option(, :path, :patch) internal ||= assign_deprecated_option(, :internal, :patch) (, mapping, :patch) end match(*path_or_actions, as:, to:, controller:, action:, on:, defaults:, constraints:, anchor:, format:, path:, internal:, **mapping, via: :patch, &block) self end
#post(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block)
Define a route that only recognizes HTTP POST. For supported arguments, see [match](Base#match)
post 'bacon', to: 'food#bacon'
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 767
def post(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block) if path_or_actions.grep(Hash).any? && ( = path_or_actions. ) as = assign_deprecated_option(, :as, :post) if .key?(:as) to ||= assign_deprecated_option(, :to, :post) controller ||= assign_deprecated_option(, :controller, :post) action ||= assign_deprecated_option(, :action, :post) on ||= assign_deprecated_option(, :on, :post) defaults ||= assign_deprecated_option(, :defaults, :post) constraints ||= assign_deprecated_option(, :constraints, :post) anchor = assign_deprecated_option(, :anchor, :post) if .key?(:anchor) format = assign_deprecated_option(, :format, :post) if .key?(:format) path ||= assign_deprecated_option(, :path, :post) internal ||= assign_deprecated_option(, :internal, :post) (, mapping, :post) end match(*path_or_actions, as:, to:, controller:, action:, on:, defaults:, constraints:, anchor:, format:, path:, internal:, **mapping, via: :post, &block) self end
#put(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block)
Define a route that only recognizes HTTP PUT. For supported arguments, see [match](Base#match)
put 'bacon', to: 'food#bacon'
# File 'actionpack/lib/action_dispatch/routing/mapper.rb', line 815
def put(*path_or_actions, as: DEFAULT, to: nil, controller: nil, action: nil, on: nil, defaults: nil, constraints: nil, anchor: nil, format: nil, path: nil, internal: nil, **mapping, &block) if path_or_actions.grep(Hash).any? && ( = path_or_actions. ) as = assign_deprecated_option(, :as, :put) if .key?(:as) to ||= assign_deprecated_option(, :to, :put) controller ||= assign_deprecated_option(, :controller, :put) action ||= assign_deprecated_option(, :action, :put) on ||= assign_deprecated_option(, :on, :put) defaults ||= assign_deprecated_option(, :defaults, :put) constraints ||= assign_deprecated_option(, :constraints, :put) anchor = assign_deprecated_option(, :anchor, :put) if .key?(:anchor) format = assign_deprecated_option(, :format, :put) if .key?(:format) path ||= assign_deprecated_option(, :path, :put) internal ||= assign_deprecated_option(, :internal, :put) (, mapping, :put) end match(*path_or_actions, as:, to:, controller:, action:, on:, defaults:, constraints:, anchor:, format:, path:, internal:, **mapping, via: :put, &block) self end