Documentation ¶
Index ¶
- func CRON(engine IEngine, spec string, job func())
- func DELETE[T any](engine IEngine, route string, handler ApiHandler[T], ...)
- func DELETECached[T any](engine IEngine, route string, handler ApiHandler[T], duration time.Duration, ...)
- func GET[T any](engine IEngine, route string, handler ApiHandler[T], ...)
- func GETCached[T any](engine IEngine, route string, handler ApiHandler[T], duration time.Duration, ...)
- func GetError(code string, locale ...string) string
- func POST[T any](engine IEngine, route string, handler ApiHandler[T], ...)
- func POSTCached[T any](engine IEngine, route string, handler ApiHandler[T], duration time.Duration, ...)
- func PUT[T any](engine IEngine, route string, handler ApiHandler[T], ...)
- func PUTCached[T any](engine IEngine, route string, handler ApiHandler[T], duration time.Duration, ...)
- func RegisterError(code, message string, locale ...string)
- func WS[T any](engine IEngine, route string, handler WsHandler[T], ...)
- type ApiHandler
- type ApiService
- type Context
- func (ctx *Context[T]) BearerToken() string
- func (ctx *Context[T]) ClientIP() string
- func (ctx *Context[T]) Err(code string, locale ...string)
- func (ctx *Context[T]) GetEngine() IEngine
- func (ctx *Context[T]) GetGinCtx() *gin.Context
- func (ctx *Context[T]) GetIsFile() bool
- func (ctx *Context[T]) GetIsResponded() bool
- func (ctx *Context[T]) GetPage() *sql.Pagination
- func (ctx *Context[T]) GetRequest() *T
- func (ctx *Context[T]) GetResponse() *Response
- func (ctx *Context[T]) GetSort() *sql.Sort
- func (ctx *Context[T]) GetStartTime() time.Time
- func (ctx *Context[T]) OK(data any, page ...*sql.Pagination)
- func (ctx *Context[T]) OKDownload(bytes []byte, filename ...string)
- func (ctx *Context[T]) OKFile(bytes []byte, filename ...string)
- func (ctx *Context[T]) SetEngine(engine IEngine)
- func (ctx *Context[T]) SetGinCtx(ginCtx *gin.Context)
- func (ctx *Context[T]) SetIsFile(isFile bool)
- func (ctx *Context[T]) SetIsResponded(isResp bool)
- func (ctx *Context[T]) SetPage(page *sql.Pagination)
- func (ctx *Context[T]) SetRequest(request *T)
- func (ctx *Context[T]) SetResponse(response *Response)
- func (ctx *Context[T]) SetSort(sort *sql.Sort)
- func (ctx *Context[T]) SetStartTime(startTime time.Time)
- func (ctx *Context[T]) UserAgent() string
- type Engine
- type Error
- type IContext
- type IEngine
- type IError
- type MockContextParams
- type Response
- type WsHandler
- type WsService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DELETE ¶
func DELETE[T any](engine IEngine, route string, handler ApiHandler[T], middleware ...gin.HandlerFunc)
func DELETECached ¶
func DELETECached[T any](engine IEngine, route string, handler ApiHandler[T], duration time.Duration, middleware ...gin.HandlerFunc)
func GET ¶
func GET[T any](engine IEngine, route string, handler ApiHandler[T], middleware ...gin.HandlerFunc)
func GETCached ¶
func GETCached[T any](engine IEngine, route string, handler ApiHandler[T], duration time.Duration, middleware ...gin.HandlerFunc)
func POST ¶
func POST[T any](engine IEngine, route string, handler ApiHandler[T], middleware ...gin.HandlerFunc)
func POSTCached ¶
func POSTCached[T any](engine IEngine, route string, handler ApiHandler[T], duration time.Duration, middleware ...gin.HandlerFunc)
func PUT ¶
func PUT[T any](engine IEngine, route string, handler ApiHandler[T], middleware ...gin.HandlerFunc)
func PUTCached ¶
func PUTCached[T any](engine IEngine, route string, handler ApiHandler[T], duration time.Duration, middleware ...gin.HandlerFunc)
func RegisterError ¶
Types ¶
type ApiHandler ¶
type ApiHandler[T any] func() ApiService[T]
func (ApiHandler[T]) GinHandler ¶
func (h ApiHandler[T]) GinHandler(engine IEngine) gin.HandlerFunc
type ApiService ¶
type Context ¶
type Context[T any] struct { Engine IEngine GinCtx *gin.Context Page *sql.Pagination Sort *sql.Sort Request *T Response *Response StartTime time.Time IsFile bool IsResp bool }
func (*Context[T]) BearerToken ¶
func (*Context[T]) GetIsResponded ¶
func (*Context[T]) GetPage ¶
func (ctx *Context[T]) GetPage() *sql.Pagination
func (*Context[T]) GetRequest ¶
func (ctx *Context[T]) GetRequest() *T
func (*Context[T]) GetResponse ¶
func (*Context[T]) GetStartTime ¶
func (*Context[T]) OKDownload ¶ added in v1.1.9
func (*Context[T]) SetIsResponded ¶
func (*Context[T]) SetPage ¶
func (ctx *Context[T]) SetPage(page *sql.Pagination)
func (*Context[T]) SetRequest ¶
func (ctx *Context[T]) SetRequest(request *T)
func (*Context[T]) SetResponse ¶
func (*Context[T]) SetStartTime ¶
type IContext ¶
type IContext[T any] interface { GetEngine() IEngine SetEngine(engine IEngine) GetGinCtx() *gin.Context SetGinCtx(ginCtx *gin.Context) GetPage() *sql.Pagination SetPage(page *sql.Pagination) GetSort() *sql.Sort SetSort(sort *sql.Sort) GetResponse() *Response SetResponse(resp *Response) GetRequest() *T SetRequest(req *T) GetStartTime() time.Time SetStartTime(startTime time.Time) GetIsFile() bool SetIsFile(isFile bool) GetIsResponded() bool SetIsResponded(isResp bool) ClientIP() string UserAgent() string BearerToken() string OK(data any, page ...*sql.Pagination) OKFile(bytes []byte, filename ...string) OKDownload(bytes []byte, filename ...string) Err(code string, locale ...string) }
func MockContext ¶
func MockContext[T any](params MockContextParams[T]) IContext[T]
type IEngine ¶
type IError ¶
type MockContextParams ¶
type Response ¶
type Response struct { Success bool `json:"success"` Duration int64 `json:"duration"` Pagination *sql.Pagination `json:"pagination,omitempty"` Error *Error `json:"error,omitempty"` Data interface{} `json:"data,omitempty"` }
type WsHandler ¶
func (WsHandler[T]) GinHandler ¶
func (h WsHandler[T]) GinHandler(engine IEngine) gin.HandlerFunc
Source Files ¶
Click to show internal directories.
Click to hide internal directories.