28 lines
524 B
Markdown
28 lines
524 B
Markdown
![downloads](https://img.shields.io/npm/dt/@gm5/response.svg)
|
|
![version](https://img.shields.io/npm/v/@gm5/response.svg)
|
|
|
|
# @gm5/response
|
|
|
|
> `@gm5/response` 对Http的response进一步封装, 提供常用的API.
|
|
|
|
## 安装
|
|
|
|
```bash
|
|
npm install @gm5/response
|
|
```
|
|
|
|
## 使用
|
|
|
|
```javascript
|
|
import Response from '@gm5/response'
|
|
import http from 'http'
|
|
|
|
http
|
|
.createServer((req, res) => {
|
|
let response = new Response(req, res)
|
|
|
|
response.type = 'html'
|
|
response.body = '<h1>hello world</h1>'
|
|
})
|
|
.listen(3000)
|
|
``` |