Documentation
¶
Index ¶
- Constants
- Variables
- func AppendController(c Controller)
- func GetRequestLogger(c *gin.Context) *slog.Logger
- type API
- func (e *API) AddError(err error) *API
- func (e *API) Bind(d any, bindings ...binding.Binding) *API
- func (*API) Create(c *gin.Context)
- func (*API) Delete(c *gin.Context)
- func (e *API) Err(code int, msg ...string)
- func (*API) Get(c *gin.Context)
- func (*API) Handlers() gin.HandlersChain
- func (*API) List(c *gin.Context)
- func (e *API) Make(c *gin.Context) *API
- func (e *API) OK(data any, msg ...string)
- func (*API) Other(_ *gin.RouterGroup)
- func (e *API) PageOK(result any, count int64, pageIndex int64, pageSize int64, msg ...string)
- func (*API) Path() string
- func (e *API) SetEngine(engine *gin.RouterGroup)
- func (*API) Update(c *gin.Context)
- type Action
- type Controller
- type Page
- type Response
- type Responses
- type Searcher
Constants ¶
View Source
const ( // Get action Get = "get" // Base action Base = "base" // Delete action Delete = "delete" // Search action Search = "search" // Control action Control = "control" // Create action Create = "create" // Update action Update = "update" )
Variables ¶
View Source
var AuthHandler gin.HandlerFunc
AuthHandler 鉴权
View Source
var Controllers = make([]Controller, 0)
Controllers controllers
View Source
var DefaultLanguage = "zh-CN"
DefaultLanguage 默认语言
View Source
var VerifyHandler func(ctx *gin.Context) security.Verifier
Functions ¶
func AppendController ¶
func AppendController(c Controller)
AppendController add controllers to Controllers
Types ¶
type API ¶
type API struct {
Context *gin.Context
Log *slog.Logger
Error error
// contains filtered or unexported fields
}
API api接口
type Controller ¶
type Controller interface {
// Path http path
Path() string
// Handlers middlewares
Handlers() gin.HandlersChain
// GetAction get action
GetAction(string) Action
// Other handler
Other(*gin.RouterGroup)
// GetKey get key
GetKey() string
// GetProvider get provider
GetProvider() fmt.Stringer
}
Controller controllers
type Page ¶
type Page struct {
Count int64 `json:"total"`
Current int64 `json:"current"`
PageSize int64 `json:"pageSize"`
}
Page page
type Response ¶
type Response struct {
Success bool `json:"success,omitempty"`
Status string `json:"status,omitempty"`
Code int `json:"code,omitempty"`
ErrorCode string `json:"errorCode,omitempty"`
ErrorMessage string `json:"errorMessage,omitempty"`
ShowType uint8 `json:"showType,omitempty"`
TraceID string `json:"traceId,omitempty"`
Host string `json:"host,omitempty"`
}
Response response
type Responses ¶
type Responses interface {
SetCode(int)
SetTraceID(string)
SetMsg(...string)
SetList(any)
SetStatus(string)
Clone() Responses
Error(ctx *gin.Context, code int, err error, msg ...string)
OK(ctx *gin.Context, data any)
PageOK(ctx *gin.Context, result any, count, pageIndex, pageSize int64)
}
Responses responses
var Default Responses = &response{}
Default 默认返回
Source Files
¶
Click to show internal directories.
Click to hide internal directories.