class DirectoryIndex < ClientRedirect

Inherits from
ClientRedirect

Inherited Methods

From Utopia::Redirection::ClientRedirect:

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

Definitions

def initialize(app, index: "index")

Initialize directory-index redirection.

Signature

parameter app Interface(:call)

The downstream application.

parameter index Integer

The index.

Implementation

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

def freeze

Freeze this object and its internal state.

Signature

returns self

This object.

Implementation

def freeze
	return self if frozen?
	
	@index.freeze
	
	return super
end

def [](path)

Redirect a directory path to its index path.

Signature

parameter path String

The normalized request path.

returns Protocol::HTTP::Response | Nil

The redirect response when the path ends with /.

Implementation

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