Skip to content

请求与响应结构 | Structure of Request & Response

Heran Yang edited this page Jun 28, 2023 · 5 revisions

请求 | Request

所有的请求均为 JSON 格式。
All requests should be formatted in JSON.

具体格式需参照 API 内定义。
The specific formats need to refer to the definition in the API Part.

响应 | Response

type Respond struct {
	Code  int             `json:"code"`
	Msg   string          `json:"msg"`
	Data  []interface{}{} `json:"data"`
}

其中:

  • code:请求状态码,参考「错误码 | Error Code」一节
    code: Request status code. Refer to Section「错误码 | Error Code」
  • msg:响应信息,若请求状态码为 0,则为 success,否则为失败原因
    msg: Response message. If the request status code is 0, the message is success. Otherwise, the message is the error message
  • data:如果响应成功,则包含响应数据段,否则无此字段
    data: If the request responds successfully, it contains the data requests. Otherwise, the field is omitted

错误码 | Error Code

  • 0:请求成功 / Respond successfully
  • 1000:内部错误 / Internal server error
  • 1001:权限不足 / Permission denied
  • 1002:请求中信息有误 / Wrong info in the request
  • 1003:不在报名时间段内 / Out of the registration period