class Rewrite < ClientRedirect

Inherits from
ClientRedirect

Inherited Methods

From Utopia::Redirection::ClientRedirect:

Rewrite requests that match the given pattern to a single destination.

Definitions

def initialize(app, patterns, status: 301)

Initialize exact-path redirections.

Signature

parameter app Interface(:call)

The downstream application.

parameter patterns Hash

The path rewrite patterns.

parameter status Integer

The status.

Implementation

def initialize(app, patterns, status: 301)
	@patterns = patterns
	
	super(app, status: status)
end

def freeze

Freeze this object and its internal state.

Signature

returns self

This object.

Implementation

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

def [](path)

Redirect a path found in the rewrite map.

Signature

parameter path String

The normalized request path.

returns Protocol::HTTP::Response | Nil

The redirect response when the path is mapped.

Implementation

def [] path
	if location = @patterns[path]
		return redirect(location)
	end
end