Class: Utopia::Redirection::DirectoryIndex
- Inherits:
-
ClientRedirect
- Object
- Protocol::HTTP::Middleware
- ClientRedirect
- Utopia::Redirection::DirectoryIndex
- Defined in:
- lib/utopia/redirection/directory_index.rb
Overview
Redirect urls that end with a /, e.g. directories.
Instance Attribute Summary
Attributes inherited from ClientRedirect
Instance Method Summary collapse
-
#[](path) ⇒ Object
Redirect a directory path to its index path.
-
#freeze ⇒ Object
Freeze this object and its internal state.
-
#initialize(app, index: "index") ⇒ DirectoryIndex
constructor
Initialize directory-index redirection.
Methods inherited from ClientRedirect
#cache_control, #call, #make_headers, #redirect
Constructor Details
#initialize(app, index: "index") ⇒ DirectoryIndex
Initialize directory-index redirection.
15 16 17 18 19 |
# File 'lib/utopia/redirection/directory_index.rb', line 15 def initialize(app, index: "index") @index = index super(app) end |
Instance Method Details
#[](path) ⇒ Object
Redirect a directory path to its index path.
34 35 36 37 38 |
# File 'lib/utopia/redirection/directory_index.rb', line 34 def [] path if path.end_with?("/") return redirect(path + @index) end end |
#freeze ⇒ Object
Freeze this object and its internal state.
23 24 25 26 27 28 29 |
# File 'lib/utopia/redirection/directory_index.rb', line 23 def freeze return self if frozen? @index.freeze return super end |