handler

package
v0.0.0-...-4dc2fe1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ResponseCodeSuccess 默认请求成功返回,返回内容参照阿里Java研发规范
	ResponseCodeSuccess     = "00000"
	ResponseCodeSystemError = "B0001"
)
View Source
const (
	ResponseMessageSuccess     = "success"
	ResponseMessageSystemError = "system error"
)

Variables

This section is empty.

Functions

func GinWrapper

func GinWrapper(handlerFunc func(ctx *GinCtx) (responseData interface{}, err error)) gin.HandlerFunc

GinWrapper 请求方法包装

Types

type GinCtx

type GinCtx struct {
	*gin.Context
}

func (*GinCtx) Debug

func (g *GinCtx) Debug(format string, a ...interface{})

func (*GinCtx) Error

func (g *GinCtx) Error(format string, a ...interface{})

func (*GinCtx) Info

func (g *GinCtx) Info(format string, a ...interface{})

func (*GinCtx) Warn

func (g *GinCtx) Warn(format string, a ...interface{})

type RequestData

type RequestData interface{}

type Response

type Response struct {
	Code    string       `json:"code"`     // 自定义状态码
	Message string       `json:"message"`  // 响应描述
	Data    ResponseData `json:"data"`     // 响应数据
	TraceId string       `json:"trace_id"` // traceIdKey
}

Response 通用响应体

func NewResponseError

func NewResponseError(err error, traceId string) *Response

func NewResponseSuccess

func NewResponseSuccess(data interface{}, traceId string) *Response

NewResponseSuccess 请求成功

func NewResponseSystemError

func NewResponseSystemError(traceId string) *Response

type ResponseData

type ResponseData interface{}

ResponseData 响应数据

Jump to

Keyboard shortcuts

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