verify

package
v1.0.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package verify 校验

Package verify 校验

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPJson

func HTTPJson(request *model.Request, response *http.Response, body []byte) (code int, isSucceed bool)

HTTPJson 通过返回的Body 判断 返回示例: {"code":200,"msg":"Success","data":{}} code 默认将http code作为返回码,http code 为200时 取body中的返回code

func HTTPStatusCode

func HTTPStatusCode(request *model.Request, response *http.Response, body []byte) (code int, isSucceed bool)

HTTPStatusCode 通过 HTTP 状态码判断是否请求成功

func WebSocketJSON

func WebSocketJSON(request *model.Request, seq string, msg []byte) (code int, isSucceed bool)

WebSocketJSON 通过返回的Body 判断 返回示例: {"seq":"1566276523281-585638","cmd":"heartbeat","response":{"code":200,"codeMsg":"Success","data":null}} code 取body中的返回code

Types

type ResponseJSON

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

ResponseJSON 返回数据结构体

type WebSocketResponseJSON

type WebSocketResponseJSON struct {
	Seq      string `json:"seq"`
	Cmd      string `json:"cmd"`
	Response struct {
		Code    int         `json:"code"`
		CodeMsg string      `json:"codeMsg"`
		Data    interface{} `json:"data"`
	} `json:"response"`
}

WebSocketResponseJSON 返回数据结构体,返回值为json

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL