Skip to content
This repository

http_status_exceptions is a simple plugin to enable the use of exceptions to generate responses with different HTTP status codes. This can be used to cleanup your controller in handling edge-cases.

For instance, you could raise a HTTPStatus::Forbidden exception if the user is not authorized to perform restricted action, or you could raise a HTTPStatus::PaymentRequired if the user should renew its membership to your website. By default, this plugin will send an empty response with the desired HTTP status code. It is possible to respond with a customized error page as well. In the case of HTTPStatus::PaymentRequired, a response with a credit card payment form can be used, so that the user easily can renew his membership.

Disclaimer

This plugin is written by Willem van Bergen together some other Contributors and is released under the MIT license. It consists of about 40 lines of meta-programming. It is based on the concepts of my blog post Putting HTTP status codes to use with Rails although the implementation is significantly different.

Something went wrong with that request. Please try again.