Class: Redirect::App
- Inherits:
-
Object
- Object
- Redirect::App
- Defined in:
- lib/redirect/app.rb
Defined Under Namespace
Classes: StaticFile
Instance Attribute Summary collapse
-
#public_dir ⇒ Object
Returns the value of attribute public_dir.
-
#redirects ⇒ Object
readonly
Returns the value of attribute redirects.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(*redirects) ⇒ App
constructor
A new instance of App.
Constructor Details
Instance Attribute Details
#public_dir ⇒ Object
Returns the value of attribute public_dir.
26 27 28 |
# File 'lib/redirect/app.rb', line 26 def public_dir @public_dir end |
#redirects ⇒ Object (readonly)
Returns the value of attribute redirects.
25 26 27 |
# File 'lib/redirect/app.rb', line 25 def redirects @redirects end |
Instance Method Details
#call(env) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/redirect/app.rb', line 34 def call(env) @env = env @request = Rack::Request.new(env) if static_file.available? return static_response end if request.fullpath == '/sitemap.xml' return sitemap_response end # if request.fullpath == '/' && index_file.available? # return index_response # end @redirects.each do |r| if r.matches?(request.fullpath) return redirects_response(r) end end not_found_response end |