Documentation
¶
Index ¶
- Variables
- func NewGinProcessor() (gone.Goner, gone.GonerId, gone.GonerOption)
- func NewGinProxy() (gone.Goner, gone.GonerId, gone.GonerOption)
- func NewGinResponser() (gone.Goner, gone.GonerId, gone.GonerOption)
- func NewGinRouter() (gone.Goner, gone.GonerId, gone.GonerOption)
- func NewGinServer() (gone.Goner, gone.GonerId, gone.GonerOption, gone.GonerOption)
- func NewHttInjector() (gone.Goner, gone.GonerId, gone.GonerOption)
- func Priest(cemetery gone.Cemetery) error
- type BindFieldFunc
- type BindStructFunc
- type BusinessError
- type Context
- type Controller
- type CustomResponseWriter
- type HandleProxyToGin
- type HandlerFunc
- type HttInjector
- type IRouter
- type IRoutes
- type MountError
- type OriginContent
- type Responser
- type RouteGroup
- type RouterGroupName
- type SSE
- type Sse
- type WrappedDataFunc
- type XContext
Constants ¶
This section is empty.
Variables ¶
var NewBusinessError = gone.NewBusinessError
NewBusinessError 新建`业务错误`
var NewInnerError = gone.NewInnerError
NewInnerError 新建`内部错误`
var NewParameterError = gone.NewParameterError
NewParameterError 新建`参数错误`
var RequestIdHeaderKey = "X-Request-ID"
var ToError = gone.ToError
ToError 转为错误
var TraceIdHeaderKey = "X-Trace-ID"
Functions ¶
func NewGinProcessor ¶
NewGinProcessor 创建系统级的`Processor`,该处理器将在路由上挂载多个中间件 `trace`,负责提供健康检查响应(需要在配置文件中设置健康检查的路径`server.health-check`) 和 为请求绑定唯一的`traceID` `recovery`,负责恢复请求内发生panic `statRequestTime`,用于在日志中打印统计的请求耗时,可以通过设置配置项(`server.log.show-request-time=false`)来关闭 `accessLog`,用于在日志中打印请求、响应信息
func NewGinProxy ¶
NewGinProxy 新建代理器
func NewGinResponser ¶
NewGinResponser 新建系统默认的响应处理器 注入的ID为:gone-gin-responser (`gone.IdGoneGinResponser`)
func NewGinRouter ¶
NewGinRouter 用于创建系统根路由
func NewGinServer ¶
func NewGinServer() (gone.Goner, gone.GonerId, gone.GonerOption, gone.GonerOption)
func NewHttInjector ¶ added in v0.3.0
Types ¶
type BindFieldFunc ¶ added in v1.0.0
type BindStructFunc ¶ added in v1.0.0
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 ¶
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) 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 ¶
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 ¶
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 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 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 Sse ¶ added in v0.3.0
type Sse struct {
Writer gin.ResponseWriter
}