跳至内容 跳至搜索
方法
C
D
G
O
P

实例公共方法

connect(*args, &block)

定义一个识别 HTTP CONNECT(和 GET)请求的路由。更具体地说,这识别了 HTTP/1 协议升级请求和具有协议伪报头的 HTTP/2 CONNECT 请求。有关支持参数,请参阅 match

connect 'live', to: 'live#index'
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 760
def connect(*args, &block)
  map_method([:get, :connect], args, &block)
end

delete(*args, &block)

定义一个仅识别 HTTP DELETE 的路由。有关支持参数,请参阅 match

delete 'broccoli', to: 'food#broccoli'
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 742
def delete(*args, &block)
  map_method(:delete, args, &block)
end

get(*args, &block)

定义一个仅识别 HTTP GET 的路由。有关支持参数,请参阅 match

get 'bacon', to: 'food#bacon'
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 710
def get(*args, &block)
  map_method(:get, args, &block)
end

options(*args, &block)

定义一个仅识别 HTTP OPTIONS 的路由。有关支持参数,请参阅 match

options 'carrots', to: 'food#carrots'
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 750
def options(*args, &block)
  map_method(:options, args, &block)
end

patch(*args, &block)

定义一个仅识别 HTTP PATCH 的路由。有关支持参数,请参阅 match

patch 'bacon', to: 'food#bacon'
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 726
def patch(*args, &block)
  map_method(:patch, args, &block)
end

post(*args, &block)

定义一个仅识别 HTTP POST 的路由。有关支持参数,请参阅 match

post 'bacon', to: 'food#bacon'
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 718
def post(*args, &block)
  map_method(:post, args, &block)
end

put(*args, &block)

定义一个仅识别 HTTP PUT 的路由。有关支持参数,请参阅 match

put 'bacon', to: 'food#bacon'
# File actionpack/lib/action_dispatch/routing/mapper.rb, line 734
def put(*args, &block)
  map_method(:put, args, &block)
end