httpx

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Failure added in v0.1.4

func Failure(render JSONResponseRender, cause error)

func SetDefaultConvertErrorFunc added in v0.1.4

func SetDefaultConvertErrorFunc(f ConvertErrorFunc)

func Success

func Success(render JSONResponseRender, message string, data ...interface{})

Types

type ConvertErrorFunc added in v0.1.4

type ConvertErrorFunc func(err error) errorsx.Error

type FailureResponse added in v0.1.4

type FailureResponse struct {
	// 错误码,跟 http-status 一致,并且在 grpc 中可以转换成 grpc-status
	Code int `json:"code"`
	// 错误原因,定义为业务判定错误码
	Reason string `json:"reason"`
	// 错误信息,为用户可读的信息,可作为用户提示内容
	Message   string                 `json:"message"`
	Details   map[string]interface{} `json:"details,omitempty"`
	Timestamp time.Time              `json:"timestamp"`
}

type JSONResponseRender added in v0.1.4

type JSONResponseRender interface {
	JSON(code int, data interface{})
}

type SuccessResponse

type SuccessResponse struct {
	Code      int         `json:"code"`
	Message   string      `json:"message"`
	Data      interface{} `json:"data,omitempty"`
	Timestamp time.Time   `json:"timestamp"`
}

Jump to

Keyboard shortcuts

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