Package Exports
- http-status
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (http-status) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
HTTP Status code for Node
Utility to interact with HTTP status code.
Usage
Once you require this module, you may call it with either an HTTP code or a message name. With an HTTP code, you will get the message name while with a message name you will get an HTTP code. Simple.
API
This module is very simple. A documentation would be more complicate than reading the original code.
API sample
var HTTPStatus = require('http-status');
// Print "Internal Server Error"
console.log(HTTPStatus[500]);
// Print 500
console.log(HTTPStatus.INTERNAL_SERVER_ERROR);
Express sample
var express = require('express'),
redis = require('redis'),
HTTPStatus = require('http-status');
var app = express.createServer();
app.get('/', function (req, res) {
var client = redis.createClient();
client.ping(function (err, msg) {
if (err) {
return res.send(HTTPStatus.INTERNAL_SERVER_ERROR);
}
res.send(msg, HTTPStatus.OK);
});
});
app.listen(3000);
Contributors
David Worms : <https://github.com/wdavidw>
Daniel Gasienica : <https://github.com/gasi>
- Rodrigo : rfsbraz@gmail.com
- Paul Vollmer : paul.vollmer@fh-potsdam.de