Blame view

node_modules/http-status/README.md 1.38 KB
f7563de62   Palak Handa   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
  [![Build Status](https://secure.travis-ci.org/wdavidw/node-http-status.png)](http://travis-ci.org/wdavidw/node-http-status)
  
  # 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](./src/index.litcoffee).
  
  ### API sample
  
  ```javascript
    var HTTPStatus = require('http-status');
  
    // Print "Internal Server Error"
    console.log(HTTPStatus[500]);
  
    // Print 500
    console.log(HTTPStatus.INTERNAL_SERVER_ERROR);
  ```
  
  ### Express sample
  
  ```javascript
    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>