Documentation ¶
Overview ¶
Package http @file : code.go @author : china.gdxs@gmail.com @time : 2023/12/21 15:06 @Description:
Package http @file : codec.go @author : china.gdxs@gmail.com @time : 2023/11/7 17:34 @Description:
Package http @file : http.go @author : china.gdxs@gmail.com @time : 2023/11/7 17:30 @Description:
Package http @file : middleware.go @author : china.gdxs@gmail.com @time : 2023/11/7 17:35 @Description:
Package http @file : mw.logger.go @author : china.gdxs@gmail.com @time : 2023/12/20 14:48 @Description: 记录系统日志
Package http @file : mw.validate.go @author : china.gdxs@gmail.com @time : 2023/12/20 15:14 @Description:
Package http @file : options.go @author : china.gdxs@gmail.com @time : 2023/11/8 11:32 @Description:
Index ¶
Constants ¶
const (
ErrValidate int = 110000
)
const OperationKey = "operation"
Variables ¶
This section is empty.
Functions ¶
func DefaultRequestDecoder ¶
DefaultRequestDecoder decodes the request body to object.
Types ¶
type DecodeRequestFunc ¶
DecodeRequestFunc is decode request func.
type EncodeResponseFunc ¶
EncodeResponseFunc is encode response func.
type ErrCode ¶
type ErrCode struct { // C refers to the code of the ErrCode. C int // HTTP status that should be used for the associated error code. HTTP int // External (user) facing error text. Ext string // Ref specify the reference document. Ref string }
ErrCode implements `github.com/marmotedu/errors`.Coder interface.
func (ErrCode) HTTPStatus ¶
HTTPStatus returns the associated HTTP status code, if any. Otherwise, returns 200.
type Middleware ¶
Middleware is HTTP/gRPC transport middleware.
func Chain ¶
func Chain(m ...Middleware) Middleware
Chain returns a Middleware that specifies the chained handler for endpoint.
func MwLogger ¶
func MwLogger(lg *zap.Logger) Middleware
func MwValidator2I18n ¶
func MwValidator2I18n(I18n *i18n.I18n, lg *zap.Logger) Middleware
MwValidator2I18n i18n 国际化 @param I18n @return middleware.Middleware
type Server ¶
func NewHttpServer ¶
func NewHttpServer(opts ...ServerOption) *Server
type ServerOption ¶
type ServerOption func(*Server)
ServerOption is an HTTP server option.
func Filter ¶
func Filter(filters ...gin.HandlerFunc) ServerOption
Filter with HTTP middleware option.
func RequestDecoder ¶
func RequestDecoder(dec DecodeRequestFunc) ServerOption
RequestDecoder with request decoder.
func ResponseEncoder ¶
func ResponseEncoder(enc EncodeResponseFunc) ServerOption
ResponseEncoder with response encoder.