Compare commits

...

2 Commits

Author SHA1 Message Date
4e2121dff0 chore(release): publish
- @egg/net-tool@1.9.0
2024-09-30 03:57:08 +00:00
b6c33ba0eb feat(net-tool): 支持自定义状态码响应
All checks were successful
/ release (push) Successful in 25s
2024-09-30 03:56:45 +00:00
4 changed files with 17 additions and 7 deletions

2
package-lock.json generated
View File

@ -12272,7 +12272,7 @@
},
"packages/net-tool": {
"name": "@egg/net-tool",
"version": "1.8.0",
"version": "1.9.0",
"license": "ISC",
"dependencies": {
"@egg/logger": "^1.4.3",

View File

@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.9.0](http://yingbo.im:3000/zhaoyingbo/egg_tools/compare/@egg/net-tool@1.8.0...@egg/net-tool@1.9.0) (2024-09-30)
### Features
- **net-tool:** 支持自定义状态码响应 ([b6c33ba](http://yingbo.im:3000/zhaoyingbo/egg_tools/commits/b6c33ba0ebe2be8c75b20dc4edee2ab42f7e9f11))
# [1.8.0](http://yingbo.im:3000/zhaoyingbo/egg_tools/compare/@egg/net-tool@1.7.1...@egg/net-tool@1.8.0) (2024-09-27)
### Features

View File

@ -1,6 +1,6 @@
{
"name": "@egg/net-tool",
"version": "1.8.0",
"version": "1.9.0",
"description": "Net Tools for Egg projects",
"type": "module",
"main": "src/index.ts",

View File

@ -491,13 +491,17 @@ class NetTool extends NetToolBase {
}
/**
* 200 OK的响应对
*
*
* @returns 200 OK的响应对象
* @param status -
* @param data -
* @returns
*/
empty200() {
this.logger.info("return a empty 200 response")
return new Response(null, { status: 200 })
custom(status = 200, data = null as any) {
this.logger.info(
`return a ${status} response${data ? ": " + JSON.stringify(data) : ""}`
)
return new Response(data, { status: status })
}
/**