Halt!
Sometimes we don't want a request to continue executing; maybe an error has occurred or perhaps an operation is taking too long and we would like to abort the execution of the request. Maze provides a halt!
method to controllers.
When you want a request to cease and return a particular message rather then rendering a page, you use Maze halt!
to stop the request from continue execution.
A status code of 404
was returned, and the content in render
will not be delivered to the client.
The next time you’re building a Maze application, consider using halt to simplify error handling.
Halt! and redirect_to
Unlike other frameworks Maze redirect_to
stops the current execution of the request and performs the redirection at that given time.
For example, in other frameworks you will have to do something similar to:
As you probably noticed there is an explicit return, this explicit return is something that is not needed with Maze. Since redirect_to
uses the halt!
method in the background.
Last updated