Documentation ¶
Index ¶
- Constants
- Variables
- func AdaptHandlerFunc(handler HandlerFunc) gin.HandlerFunc
- func GlobalErrorHandlerMiddleware(logger interfaces.Logger) gin.HandlerFunc
- func InitLog(opts ...zlog.Option)
- func InitValidator(language Language)
- func MultiAdaptHandlerFunc(handlers ...HandlerFunc) []gin.HandlerFunc
- func ReplaceContextMiddleware(logger interfaces.Logger) gin.HandlerFunc
- type Context
- func (c *Context) AbortWithError(e error)
- func (c *Context) PathParam(key string) string
- func (c *Context) PathParamInt(key string, defaultValue ...int) int
- func (c *Context) QueryBool(key string) (bool, error)
- func (c *Context) QueryInt(key string) (int, error)
- func (c *Context) QueryString(key string) string
- func (c *Context) RequestID() string
- func (c *Context) Success(msg string, payload any)
- func (c *Context) Validate(obj any) error
- type HandlerFunc
- type Language
- type Router
- type Server
Constants ¶
View Source
const ( Zh = "zh" En = "en" )
Variables ¶
View Source
var Log interfaces.Logger
Functions ¶
func AdaptHandlerFunc ¶
func AdaptHandlerFunc(handler HandlerFunc) gin.HandlerFunc
func GlobalErrorHandlerMiddleware ¶
func GlobalErrorHandlerMiddleware(logger interfaces.Logger) gin.HandlerFunc
func InitValidator ¶
func InitValidator(language Language)
func MultiAdaptHandlerFunc ¶
func MultiAdaptHandlerFunc(handlers ...HandlerFunc) []gin.HandlerFunc
func ReplaceContextMiddleware ¶
func ReplaceContextMiddleware(logger interfaces.Logger) gin.HandlerFunc
Types ¶
type Context ¶
type Context struct { *gin.Context Logger interfaces.Logger // contains filtered or unexported fields }
func NewContext ¶
func NewContext(c *gin.Context, logger interfaces.Logger) *Context
func (*Context) AbortWithError ¶
func (*Context) QueryString ¶
QueryString String 获取请求参数 ?username=xxx key: 参数名
type HandlerFunc ¶
type HandlerFunc func(c *Context)
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router 自定义 Router
func (*Router) DELETE ¶
func (r *Router) DELETE(path string, handlers ...HandlerFunc)
func (*Router) GET ¶
func (r *Router) GET(path string, handlers ...HandlerFunc)
func (*Router) POST ¶
func (r *Router) POST(path string, handlers ...HandlerFunc)
func (*Router) PUT ¶
func (r *Router) PUT(path string, handlers ...HandlerFunc)
func (*Router) Use ¶
func (r *Router) Use(middleware ...HandlerFunc)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.