Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: c504147861
Fetching contributors…

Cannot retrieve contributors at this time

48 lines (33 sloc) 1.057 kb

Build Status

HTTP Status code for Node

Utility to interact with HTTP status code.

Usage

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

Jump to Line
Something went wrong with that request. Please try again.