Module: WebPipe::Redirect

Included in:
Conn
Defined in:
lib/web_pipe/extensions/redirect/redirect.rb

Overview

See the docs for the extension linked from the README.

Constant Summary collapse

LOCATION_HEADER =

Location header

'Location'
RedirectCode =

Valid type for a redirect status code

Types::Strict::Integer.constrained(gteq: 300, lteq: 399)

Instance Method Summary collapse

Instance Method Details

#redirect(location, code = 302) ⇒ Object

Parameters:

  • location (String)
  • code (Integer) (defaults to: 302)


17
18
19
20
# File 'lib/web_pipe/extensions/redirect/redirect.rb', line 17

def redirect(location, code = 302)
  add_response_header(LOCATION_HEADER, location)
    .set_status(RedirectCode[code])
end