instance method connect

Ruby on Rails 8.1.2

Since v8.0.4

Available in: v8.0.4 v8.1.2

Signature

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

connect 'live', to: 'live#index'

Parameters

path_or_actions rest
as key = DEFAULT
to key = nil
controller key = nil
action key = nil
on key = nil
defaults key = nil
constraints key = nil
anchor key = false
format key = false
path key = nil
internal key = nil
mapping keyrest
block block
Source
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 884
        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? && (deprecated_options = path_or_actions.extract_options!)
            as = assign_deprecated_option(deprecated_options, :as, :connect) if deprecated_options.key?(:as)
            to ||= assign_deprecated_option(deprecated_options, :to, :connect)
            controller ||= assign_deprecated_option(deprecated_options, :controller, :connect)
            action ||= assign_deprecated_option(deprecated_options, :action, :connect)
            on ||= assign_deprecated_option(deprecated_options, :on, :connect)
            defaults ||= assign_deprecated_option(deprecated_options, :defaults, :connect)
            constraints ||= assign_deprecated_option(deprecated_options, :constraints, :connect)
            anchor = assign_deprecated_option(deprecated_options, :anchor, :connect) if deprecated_options.key?(:anchor)
            format = assign_deprecated_option(deprecated_options, :format, :connect) if deprecated_options.key?(:format)
            path ||= assign_deprecated_option(deprecated_options, :path, :connect)
            internal ||= assign_deprecated_option(deprecated_options, :internal, :connect)
            assign_deprecated_options(deprecated_options, 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

Defined in actionpack/lib/action_dispatch/routing/mapper.rb line 884 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionDispatch::Routing::Mapper::HttpHelpers

Type at least 2 characters to search.

↑↓ navigate · open · esc close