httpResult

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHttpErrCodeMsg

func GetHttpErrCodeMsg(err error) (uint32, string)

func HttpResult

func HttpResult(r *http.Request, w http.ResponseWriter, resp interface{}, err error)

HttpResult http返回结果

func HttpStatusResult

func HttpStatusResult(r *http.Request, w http.ResponseWriter, statusCode int, err error)

HttpStatusResult 返回自定义httpStatus状态码错误

func MapErrorResult

func MapErrorResult(r *http.Request, w http.ResponseWriter, code uint32, msg string)

MapErrorResult 自定义返回code和msg

func MdErrorResult

func MdErrorResult(r *http.Request, w http.ResponseWriter, msg string)

MdErrorResult 定义中间件错误

func ParamErrorResult

func ParamErrorResult(r *http.Request, w http.ResponseWriter, err error)

ParamErrorResult http 参数错误返回

Types

type NullJson

type NullJson struct{}

type ResponseErrorBean

type ResponseErrorBean struct {
	Code    uint32 `json:"code"`
	Msg     string `json:"msg"`
	TraceId string `json:"traceId"` // 链路跟踪traceId
	SpanId  string `json:"spanId"`  // 链路跟踪spanId
}

func Error

func Error(traceId, spanId string, errCode uint32, errMsg string) *ResponseErrorBean

Error 请求失败返回数据, traceId 为链路跟踪traceId, spanId为链路跟踪spanId

type ResponseSuccessBean

type ResponseSuccessBean struct {
	Code    uint32      `json:"code"`    // 业务状态码
	Msg     string      `json:"msg"`     // 业务消息
	Data    interface{} `json:"data"`    // 返回数据
	TraceId string      `json:"traceId"` // 链路跟踪traceId
	SpanId  string      `json:"spanId"`  // 链路跟踪spanId
}

func Success

func Success(traceId, spanId string, data interface{}) *ResponseSuccessBean

Success 请求成功返回数据, traceId 为链路跟踪traceId, spanId为链路跟踪spanId

Jump to

Keyboard shortcuts

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