Documentation ¶
Index ¶
- func HandleFunc(pattern string, f func(ctx *Context) []ResponseOption)
- type AppContext
- type Context
- func (ctx *Context) Deadline() (deadline time.Time, ok bool)
- func (ctx *Context) Done() <-chan struct{}
- func (ctx *Context) Err() error
- func (ctx *Context) GetBody() ([]byte, error)
- func (ctx *Context) Value(key any) any
- func (ctx *Context) WrapperGinHandleFunc(f func(ctx *Context) ResponseOptions) gin.HandlerFunc
- type Response
- type ResponseData
- type ResponseEntry
- type ResponseOption
- func Data(data ResponseData) ResponseOption
- func Error(code int, message string) []ResponseOption
- func ErrorWithOpts(httpCode int, opts ...ResponseOption) []ResponseOption
- func HttpCode(code int) ResponseOption
- func Message(message string) ResponseOption
- func New(code, status int, message string, data ResponseData) []ResponseOption
- func Ok(data ResponseData) []ResponseOption
- func Status(status int) ResponseOption
- type ResponseOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleFunc ¶
func HandleFunc(pattern string, f func(ctx *Context) []ResponseOption)
Types ¶
type AppContext ¶
type AppContext struct { Config *config.AppConfig Logger *zap.Logger RedisClient *redis.Client Db *ent.Client Consumer *redisqueue.Consumer Producer *redisqueue.Producer }
func NewAppContext ¶
func (AppContext) Done ¶
func (a AppContext) Done() <-chan struct{}
func (AppContext) Err ¶
func (a AppContext) Err() error
func (AppContext) Value ¶
func (a AppContext) Value(key any) any
type Context ¶
type Context struct { *AppContext Writer http.ResponseWriter Req *http.Request }
func (*Context) WrapperGinHandleFunc ¶
func (ctx *Context) WrapperGinHandleFunc(f func(ctx *Context) ResponseOptions) gin.HandlerFunc
type Response ¶
type Response struct { HttpCode int `json:"-"` ResponseEntry }
func NewResponse ¶
func NewResponse(opts []ResponseOption) *Response
type ResponseData ¶
type ResponseData interface{}
type ResponseEntry ¶
type ResponseOption ¶
type ResponseOption interface {
// contains filtered or unexported methods
}
func Data ¶
func Data(data ResponseData) ResponseOption
func Error ¶
func Error(code int, message string) []ResponseOption
func ErrorWithOpts ¶
func ErrorWithOpts(httpCode int, opts ...ResponseOption) []ResponseOption
func HttpCode ¶
func HttpCode(code int) ResponseOption
func Message ¶
func Message(message string) ResponseOption
func New ¶
func New(code, status int, message string, data ResponseData) []ResponseOption
func Ok ¶
func Ok(data ResponseData) []ResponseOption
func Status ¶
func Status(status int) ResponseOption
type ResponseOptions ¶
type ResponseOptions = []ResponseOption
Click to show internal directories.
Click to hide internal directories.