Class: Utopia::Redirection::DirectoryIndex

Inherits:
ClientRedirect show all
Defined in:
lib/utopia/redirection.rb

Overview

Redirect urls that end with a ‘/`, e.g. directories.

Instance Attribute Summary

Attributes inherited from ClientRedirect

#max_age, #status

Instance Method Summary collapse

Methods inherited from ClientRedirect

#cache_control, #call, #freeze, #headers, #redirect

Constructor Details

#initialize(app, index: 'index') ⇒ DirectoryIndex

Returns a new instance of DirectoryIndex.



134
135
136
137
138
139
# File 'lib/utopia/redirection.rb', line 134

def initialize(app, index: 'index')
	@app = app
	@index = index
	
	super(app)
end

Instance Method Details

#[](path) ⇒ Object



141
142
143
144
145
# File 'lib/utopia/redirection.rb', line 141

def [] path
	if path.end_with?('/')
		return redirect(path + @index)
	end
end