2023-10-31 14:26:15 +08:00
|
|
|
![downloads](https://img.shields.io/npm/dt/@gm5/response.svg)
|
|
|
|
![version](https://img.shields.io/npm/v/@gm5/response.svg)
|
2020-09-16 16:01:46 +08:00
|
|
|
|
|
|
|
# @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)
|
|
|
|
|
2023-10-31 14:26:15 +08:00
|
|
|
response.type = 'html'
|
|
|
|
response.body = '<h1>hello world</h1>'
|
2020-09-16 16:01:46 +08:00
|
|
|
})
|
|
|
|
.listen(3000)
|
2023-10-31 14:26:15 +08:00
|
|
|
```
|