Koa Custom Statuses
Koa has a defined set of HTTP response codes that can be retured in a request. While they are shandard HTTP codes and will be enough most of the time, Sometimes, there is a need for creating custom codes. This module enables you to achieve just that declaring the additional codes you require in the very beginning. It also enables you to change the status message of existing status codes.
The module definition is extremely simple. Just wrap a koa function into the module along with an object containing the status code you require.
var koa = var app = app '200': 'Im Loving it!!' '499': 'Cos I can come that close to 500' '700': 'Theres the 7 series in HTTP' '999': 'Because We can'; app
There are just some basics you need to keep in mind.
- The status codes can be 3 digit numbers only.
- The codes you declare will overwrite the Koa Defaults.
- You can only use default Koa codes or the codes defined in the module. Any others will throw an error