gin

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const TooManyRequests = "Too Many Requests"

Variables

View Source
var NewBusinessError = gone.NewBusinessError

NewBusinessError 新建`业务错误`

View Source
var NewInnerError = gone.NewInnerError

NewInnerError 新建`内部错误`

View Source
var NewParameterError = gone.NewParameterError

NewParameterError 新建`参数错误`

View Source
var ToError = gone.ToError

ToError 转为错误

Functions

func NewGinProxy

func NewGinProxy() (gone.Goner, gone.GonerId)

NewGinProxy 新建代理器

func NewGinResponser

func NewGinResponser() (gone.Goner, gone.GonerId)

NewGinResponser 新建系统默认的响应处理器 注入的ID为:gone-gin-responser (`gone.IdGoneGinResponser`)

func NewGinRouter

NewGinRouter 用于创建系统根路由

func NewGinServer

func NewGinServer() (gone.Goner, gone.GonerOption, gone.GonerOption)

func NewHttInjector added in v0.3.0

func NewHttInjector() (gone.Goner, gone.GonerId)

func NewSysMiddleware added in v1.0.4

func NewSysMiddleware() (gone.Goner, gone.GonerOption, gone.GonerOption)

NewSysMiddleware create a new sys middleware

func Priest

func Priest(cemetery gone.Cemetery) error

Types

type BindFieldFunc added in v1.0.0

type BindFieldFunc func(context *gin.Context, structVale reflect.Value) error

type BindStructFunc added in v1.0.0

type BindStructFunc func(*gin.Context, reflect.Value) (reflect.Value, error)

type BusinessError

type BusinessError = gone.BusinessError

BusinessError business error Business errors are special cases in business scenarios that need to return different data types in different business contexts; essentially not considered errors, but an abstraction to facilitate business writing, allowing the same interface to have the ability to return different business codes and business data in special cases

type Context

type Context = gone.Context

Context The `gone` framework encapsulated context based on `gin` Deprecated use `gone.Context` instead

type Controller

type Controller interface {
	// Mount Route mount interface, this interface will be called before the service starts, the implementation of this function should usually return `nil`
	Mount() MountError
}

Controller interface, implemented by business code, used to mount and handle routes For usage reference [example code](https://gitlab.openviewtech.com/gone/gone-example/-/tree/master/gone-app)

type CustomResponseWriter

type CustomResponseWriter struct {
	gin.ResponseWriter
	// contains filtered or unexported fields
}

func (CustomResponseWriter) Write

func (w CustomResponseWriter) Write(b []byte) (int, error)

func (CustomResponseWriter) WriteString

func (w CustomResponseWriter) WriteString(s string) (int, error)

type HandleProxyToGin

type HandleProxyToGin interface {
	Proxy(handler ...HandlerFunc) []gin.HandlerFunc
	ProxyForMiddleware(handlers ...HandlerFunc) (arr []gin.HandlerFunc)
}

HandleProxyToGin Proxy, provides a proxy function to convert `gone.HandlerFunc` to `gin.HandlerFunc` Inject `gin.HandleProxyToGin` using Id: sys-gone-proxy (`gin.SystemGoneProxy`)

type HandlerFunc

type HandlerFunc = gone.HandlerFunc

HandlerFunc The `gone` framework route handler function

type HttInjector added in v1.0.0

type HttInjector interface {
	StartBindFuncs()
	BindFuncs() BindStructFunc
}

type IRouter

type IRouter = gone.IRouter

IRouter The `gone` framework encapsulated "router" based on `gin` Inject default router using Id: gone-gin-router (`gone.IdGoneGinRouter`)

type IRouter interface {
	// IRoutes 1. Composes `gone.IRoutes`, can define routes
	IRoutes

	// GetGinRouter 2. Can get the encapsulated ginRouter object, used to operate the original gin routes
	GetGinRouter() gin.IRouter

	// Group 3. Define route groups
	Group(string, ...HandlerFunc) RouteGroup

	LoadHTMLGlob(pattern string)
}

type IRoutes

type IRoutes = gone.IRoutes

IRoutes Routes encapsulated by the `gone` framework based on `gin`, used to define functions that handle specific requests Inject default routes using Id: gone-gin-router (`gone.IdGoneGinRouter`) To inject route dependencies into an object: ```go

func NewDependOnIRoutes() *DependOnIRoutes {
	return &DependOnIRoutes{}
}

type DependOnIRoutes struct {
	TheRoutes gone.IRoutes `gone:"gone-gin-router"` // Dependency injection system routes
}

func (*DependOnIRoutes) DoSomething()  {
	// Operate on the routes
	//...
}

```

type IRoutes interface {
	// Use Apply `gin` middleware on the route
	Use(...HandlerFunc) IRoutes

	Handle(string, string, ...HandlerFunc) IRoutes
	Any(string, ...HandlerFunc) IRoutes
	GET(string, ...HandlerFunc) IRoutes
	POST(string, ...HandlerFunc) IRoutes
	DELETE(string, ...HandlerFunc) IRoutes
	PATCH(string, ...HandlerFunc) IRoutes
	PUT(string, ...HandlerFunc) IRoutes
	OPTIONS(string, ...HandlerFunc) IRoutes
	HEAD(string, ...HandlerFunc) IRoutes
}

type Middleware added in v1.0.4

type Middleware interface {
	Process(ctx *gin.Context)
}

type MountError

type MountError = gone.GinMountError

MountError The type returned by `gin.Controller#Mount`, used to identify the implementation of `gin.Controller` to avoid being called incorrectly

type OriginContent added in v1.0.0

type OriginContent = gin.Context

type Responser

type Responser interface {
	Success(ctx XContext, data any)
	Failed(ctx XContext, err error)
	ProcessResults(context XContext, writer gin.ResponseWriter, last bool, funcName string, results ...any)
}

Responser Response handler Inject default response handler using Id: gone-gin-responser (`gone.IdGoneGinResponser`)

type RouteGroup

type RouteGroup = gone.RouteGroup

RouteGroup Route group Inject default route group using Id: gone-gin-router (`gone.IdGoneGinRouter`)

type RouteGroup interface {
	IRouter
}

type RouterGroupName

type RouterGroupName string

RouterGroupName Router group name

type SSE added in v1.0.0

type SSE interface {
	Start()
	Write(delta any) error
	End() error
	WriteError(err gone.Error) error
}

func NewSSE added in v1.0.0

func NewSSE(writer gin.ResponseWriter) SSE

type Sse added in v0.3.0

type Sse struct {
	Writer gin.ResponseWriter
}

func (*Sse) End added in v0.3.0

func (s *Sse) End() error

func (*Sse) Start added in v0.3.0

func (s *Sse) Start()

func (*Sse) Write added in v0.3.0

func (s *Sse) Write(delta any) error

func (*Sse) WriteError added in v0.3.0

func (s *Sse) WriteError(err gone.Error) error

type SysMiddleware added in v1.0.4

type SysMiddleware struct {
	gone.Flag
	// contains filtered or unexported fields
}

SysMiddleware system middleware

func (*SysMiddleware) AfterRevive added in v1.0.4

func (m *SysMiddleware) AfterRevive() error

func (*SysMiddleware) Process added in v1.0.4

func (m *SysMiddleware) Process(context *gin.Context)

type WrappedDataFunc added in v0.3.0

type WrappedDataFunc func(code int, msg string, data any) any

type XContext added in v1.0.0

type XContext interface {
	JSON(code int, obj any)
	String(code int, format string, values ...any)
	Abort()
}

Jump to

Keyboard shortcuts

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