forked from wts/wts
公开完整前后端的代码
This commit is contained in:
9
back/doc/API/common/errorType.md
Normal file
9
back/doc/API/common/errorType.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# 错误的类型
|
||||
API如果没有成功执行,会返回一个错误类型`error_type`整型,它的涵义如下:
|
||||
|
||||
- 0:没有错误
|
||||
- 1:服务器内部错误
|
||||
- 2:无效请求
|
||||
- 3:未授权访问
|
||||
- 4:数据库错误
|
||||
- 5:业务逻辑错误
|
||||
29
back/doc/API/common/responses.md
Normal file
29
back/doc/API/common/responses.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# 返回内容的格式
|
||||
本项目的API通常返回JSON,格式预览如下:
|
||||
|
||||
```JSON
|
||||
|
||||
{
|
||||
"success":true,
|
||||
"msg":"API Execution OK"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
```JSON
|
||||
|
||||
{
|
||||
"success":false,
|
||||
"msg":"API Execution met a problem",
|
||||
"error_type":2,
|
||||
"debug":"Can not bind your JSON Request body"
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
任何API都会返回`success`和`msg`字段,错误时还会返回`error_type`字段,如果打开`Debug.APIVerbose`会返回`debug`字段。
|
||||
|
||||
关于msg的内容,可以看每个API在logic包中的开头注释,具体信息位于`logic/errors.go`
|
||||
|
||||
另外在回应头里有字段`X-Request-Id`,这是我们为每个HTTP请求生成的唯一ID,可以用来在日志里查找相应的信息
|
||||
Reference in New Issue
Block a user