Skip to content

Commit 29767f4

Browse files
authored
Update README.md
1 parent 8618007 commit 29767f4

1 file changed

Lines changed: 38 additions & 2 deletions

File tree

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,38 @@
1-
# node-http-context
2-
Get HttpContext from anywhere
1+
# Node Http Context
2+
Get http context anywhere in node/express application.
3+
4+
## How to use it
5+
6+
Install: `npm install --save node-http-context`
7+
8+
``` js
9+
const express = require('express');
10+
const httpContext = require('node-http-context');
11+
12+
const app = express();
13+
// Initialize Httpcontext middleware service
14+
HttpContext.Initilize(app);
15+
// After initialize the httpcontext we can get httpcontext anywhere
16+
```
17+
18+
Get HttpContext form anywhare:
19+
20+
``` js
21+
const httpContext = require('node-http-context');
22+
23+
//Node express request object from HttpContext
24+
httpContext.Request;
25+
26+
//Node express response object from HttpContext
27+
httpContext.Response.send(HTML/STRING);
28+
httpContext.Response.json({JSON_Object});
29+
30+
//Node express Next object from HttpContext
31+
httpContext.Next();
32+
33+
//Node express session object from HttpContext
34+
httpContext.Session;
35+
```
36+
37+
## Contributors
38+
* Devesh Kumar (@dkrockcom)

0 commit comments

Comments
 (0)