Class: Rack::CanonicalHost::Redirect
- Inherits:
-
Object
- Object
- Rack::CanonicalHost::Redirect
- Defined in:
- lib/rack/canonical_host/redirect.rb
Constant Summary collapse
- HTML_TEMPLATE =
<<-HTML.gsub(/^\s+/, '') <!DOCTYPE html> <html lang="en-US"> <head><title>301 Moved Permanently</title></head> <body> <h1>Moved Permanently</h1> <p>The document has moved <a href="%s">here</a>.</p> </body> </html> HTML
Instance Method Summary collapse
- #canonical? ⇒ Boolean
-
#initialize(env, host, options = {}) ⇒ Redirect
constructor
A new instance of Redirect.
- #response ⇒ Object
Constructor Details
#initialize(env, host, options = {}) ⇒ Redirect
Returns a new instance of Redirect.
18 19 20 21 22 23 24 |
# File 'lib/rack/canonical_host/redirect.rb', line 18 def initialize(env, host, ={}) self.env = env self.host = host self.ignore = Array([:ignore]) self.conditions = Array([:if]) self.cache_control = [:cache_control] end |
Instance Method Details
#canonical? ⇒ Boolean
26 27 28 29 |
# File 'lib/rack/canonical_host/redirect.rb', line 26 def canonical? return true unless enabled? known? || ignored? end |
#response ⇒ Object
31 32 33 |
# File 'lib/rack/canonical_host/redirect.rb', line 31 def response [301, headers, [HTML_TEMPLATE % new_url]] end |