goin

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Zh = "zh"
	En = "en"
)

Variables

Functions

func AdaptHandlerFunc

func AdaptHandlerFunc(handler HandlerFunc) gin.HandlerFunc

func GlobalErrorHandlerMiddleware

func GlobalErrorHandlerMiddleware(logger interfaces.Logger) gin.HandlerFunc

func InitLog

func InitLog(opts ...zlog.Option)

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 (c *Context) AbortWithError(e error)

func (*Context) PathParam

func (c *Context) PathParam(key string) string

func (*Context) PathParamInt

func (c *Context) PathParamInt(key string, defaultValue ...int) int

func (*Context) QueryBool

func (c *Context) QueryBool(key string) (bool, error)

QueryBool Bool 获取请求参数

func (*Context) QueryInt

func (c *Context) QueryInt(key string) (int, error)

QueryInt Int 获取请求参数 ?userID=1020301230

func (*Context) QueryString

func (c *Context) QueryString(key string) string

QueryString String 获取请求参数 ?username=xxx key: 参数名

func (*Context) RequestID

func (c *Context) RequestID() string

RequestID 获取 请求 ID, 每个请求都是唯一的

func (*Context) Success

func (c *Context) Success(msg string, payload any)

func (*Context) Validate

func (c *Context) Validate(obj any) error

Vaidate 校验请求参数 obj: 需要被校验的对象

type HandlerFunc

type HandlerFunc func(c *Context)

type Language

type Language string

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router 自定义 Router

func NewRouter

func NewRouter(router gin.IRouter) *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)

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New() *Server

func (*Server) Group

func (s *Server) Group(relativePath string, handlers ...HandlerFunc) *Router

func (*Server) Run

func (s *Server) Run(addr string)

func (*Server) Use

func (s *Server) Use(middlewares ...HandlerFunc)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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