Sometimes we want to stop the program: maybe a critical error has ocurred. To immediately stop a request within a filter or route use:

You can also specify the status when halting:

halt 410
Or the body:

halt 'this will be the body'
Or both:

halt 401, 'go away!'
With headers:

halt 402, {'Content-Type' => 'text/plain'}, 'revenge'
It is of course possible to combine a template with halt:

halt erb(:error)


Casiano Rodriguez León 2015-06-18