Module: ActionDispatch::Routing::Mapper::HttpHelpers
- Included in:
- ActionDispatch::Routing::Mapper
- Defined in:
- lib/action_dispatch/routing/mapper.rb
Instance Method Summary collapse
- #delete(*args, &block) ⇒ Object
- #get(*args, &block) ⇒ Object
- #post(*args, &block) ⇒ Object
- #put(*args, &block) ⇒ Object
- #redirect(*args, &block) ⇒ Object
Instance Method Details
#delete(*args, &block) ⇒ Object
273 274 275 |
# File 'lib/action_dispatch/routing/mapper.rb', line 273 def delete(*args, &block) map_method(:delete, *args, &block) end |
#get(*args, &block) ⇒ Object
261 262 263 |
# File 'lib/action_dispatch/routing/mapper.rb', line 261 def get(*args, &block) map_method(:get, *args, &block) end |
#post(*args, &block) ⇒ Object
265 266 267 |
# File 'lib/action_dispatch/routing/mapper.rb', line 265 def post(*args, &block) map_method(:post, *args, &block) end |
#put(*args, &block) ⇒ Object
269 270 271 |
# File 'lib/action_dispatch/routing/mapper.rb', line 269 def put(*args, &block) map_method(:put, *args, &block) end |
#redirect(*args, &block) ⇒ Object
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/action_dispatch/routing/mapper.rb', line 277 def redirect(*args, &block) = args.last.is_a?(Hash) ? args.pop : {} path = args.shift || block path_proc = path.is_a?(Proc) ? path : proc { |params| path % params } status = [:status] || 301 lambda do |env| req = Request.new(env) params = [req.symbolized_path_parameters] params << req if path_proc.arity > 1 uri = URI.parse(path_proc.call(*params)) uri.scheme ||= req.scheme uri.host ||= req.host uri.port ||= req.port unless req.standard_port? body = %(<html><body>You are being <a href="#{ERB::Util.h(uri.to_s)}">redirected</a>.</body></html>) headers = { 'Location' => uri.to_s, 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s } [ status, headers, [body] ] end end |