chttp

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorEncoder

func ErrorEncoder(writer http.ResponseWriter, request *http.Request, err error)

func FromError

func FromError(resp *Resp) (*cerr.CodeError, bool)

func RequestBodyDecoder

func RequestBodyDecoder(r *nethttp.Request, i interface{}) error

func ResponseEncoder

func ResponseEncoder(writer nethttp.ResponseWriter, request *nethttp.Request, i interface{}) error

Types

type Resp

type Resp struct {
	// 业务 code
	Code cerr.ErrCode `json:"code"`
	// 用户看
	Msg string `json:"msg"`
	// 开发看
	Reason string `json:"reason"`
	// 服务器毫秒时间戳
	Timestamp string `json:"timestamp"`
	// 结构化数据
	Result json.RawMessage `json:"result"`
	// TraceID
	TraceID string `json:"trace_id"`
}

Jump to

Keyboard shortcuts

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