Documentation
¶
Index ¶
- Constants
- func NewModule() *application.ModuleBuilder
- func NewModuleDevtools() *application.ModuleBuilder
- type Connector
- type ConnectorRegistration
- type ContentTypeManager
- type ContentTypeRegistration
- type ContentTypeRegistry
- type Context
- type ContextHolder
- type Controller
- type ControllerRegistration
- type Group
- type GroupRegistration
- type Responder
- type ResponderRegistration
- type ResponderRegistry
- type Response
- type Router
- type RouterProxy
- type RouterRegistration
- type Routing
Constants ¶
const ( GroupREST = "rest" GroupStatic = "static" )
定义常用的分组名称
Variables ¶
This section is empty.
Functions ¶
func NewModule ¶
func NewModule() *application.ModuleBuilder
NewModule 导出模块 github.com/starter-go/libgin
func NewModuleDevtools ¶
func NewModuleDevtools() *application.ModuleBuilder
NewModuleDevtools 导出模块 [github.com/starter-go/libgin#devtools]
Types ¶
type ConnectorRegistration ¶
ConnectorRegistration ...
type ContentTypeManager ¶
ContentTypeManager 是文档类型管理器
type ContentTypeRegistration ¶
ContentTypeRegistration 是文档类型信息
type ContentTypeRegistry ¶
type ContentTypeRegistry interface {
ListRegistrations() []*ContentTypeRegistration
}
ContentTypeRegistry 是文档类型登记接口
type Context ¶
type Context interface {
GetConnectorByName(name string) (Connector, error)
GetGroupByName(name string) (Group, error)
GetRouterByName(name string) (Router, error)
ListControllersForGroup(groupName string) ([]*ControllerRegistration, error)
}
Context 是 libgin 上下文,它集中管理各种 libgin 资源
type ContextHolder ¶ added in v1.0.4
type ContextHolder struct {
// contains filtered or unexported fields
}
ContextHolder 用来绑定 gin.Context & context.Context
func BindContext ¶ added in v1.0.4
func BindContext(c *gin.Context) *ContextHolder
BindContext 绑定 gin.Context & context.Context
func GetContextHolder ¶ added in v1.0.4
func GetContextHolder(cc context.Context) (*ContextHolder, error)
GetContextHolder 取 ContextHolder
func (*ContextHolder) GinContext ¶ added in v1.0.4
func (inst *ContextHolder) GinContext() *gin.Context
GinContext 获取绑定的 gin.Context
type Controller ¶
type Controller interface {
Registration() *ControllerRegistration
}
Controller 表示一个 gin 控制器
type ControllerRegistration ¶
type ControllerRegistration struct {
Groups []string // 分组名称, 以 ',' 号分隔多个名称,如果为空表示默认分组
Route func(rp RouterProxy) error // 控制器
}
ControllerRegistration 是控制器注册信息
type Group ¶
type Group interface {
Registration() *GroupRegistration
Route(r Router) error
}
Group ...
type GroupRegistration ¶
GroupRegistration ...
type Responder ¶
type Responder interface {
ResponderRegistry
Accept(resp *Response) bool
Send(resp *Response)
}
Responder 是 REST 响应发送器的接口
type ResponderRegistration ¶ added in v1.0.2
type ResponderRegistration struct {
Priority int // 优先级,数值越大,越先处理
Name string
Enabled bool
Responder Responder
}
ResponderRegistration 是 Responder 的注册信息
type ResponderRegistry ¶ added in v1.0.2
type ResponderRegistry interface {
Registration() *ResponderRegistration
}
ResponderRegistry 是 Responder 的注册接口
type Response ¶
type Response struct {
Context *gin.Context
Status int
Error error
Responder string // 用于选择 Responder,它的值为 ResponderRegistration.Name
Data any
}
Response 表示一个 REST 响应结果
type Router ¶
type Router interface {
Registration() *RouterRegistration
Engine() *gin.Engine
}
Router ...
type RouterProxy ¶ added in v1.0.5
type RouterProxy interface {
For(path string) RouterProxy
Route(r *Routing)
Handle(method string, path string, h ...gin.HandlerFunc)
NoMethod(h ...gin.HandlerFunc)
NoRoute(h ...gin.HandlerFunc)
GET(path string, h ...gin.HandlerFunc)
POST(path string, h ...gin.HandlerFunc)
PUT(path string, h ...gin.HandlerFunc)
DELETE(path string, h ...gin.HandlerFunc)
}
RouterProxy ...
type RouterRegistration ¶
RouterRegistration ...