Documentation ¶
Index ¶
- Constants
- Variables
- func FailHandler(ctx *fasthttp.RequestCtx, data string)
- func FailServerInternalErrorHandler(ctx *fasthttp.RequestCtx, data string)
- func NotFoundHandler(ctx *fasthttp.RequestCtx)
- func RestSuccessHandler(ctx *fasthttp.RequestCtx, data any)
- func SuccessHandler(ctx *fasthttp.RequestCtx, data string)
- type CreatorFunc
- type HandlerCreator
- type HandlerFactory
- type IHandler
Constants ¶
View Source
const ( OneReturnValueAndIsError returnValuesType // only return value and is error OneReturnValueAndNotError // only return value and not an error )
View Source
const (
Ok = "Ok"
)
Variables ¶
View Source
var ErrMethodPrefix = errors.New("invalid method name prefix")
View Source
var Factory = HandlerFactory{ constant.MethodGet: defaultHandlerCreator, constant.MethodPost: defaultHandlerCreator, constant.MethodPut: defaultHandlerCreator, constant.MethodDelete: defaultHandlerCreator, }
Functions ¶
func FailHandler ¶
func FailHandler(ctx *fasthttp.RequestCtx, data string)
func FailServerInternalErrorHandler ¶
func FailServerInternalErrorHandler(ctx *fasthttp.RequestCtx, data string)
FailServerInternalErrorHandler Internal Server Error
func NotFoundHandler ¶
func NotFoundHandler(ctx *fasthttp.RequestCtx)
func RestSuccessHandler ¶
func RestSuccessHandler(ctx *fasthttp.RequestCtx, data any)
func SuccessHandler ¶
func SuccessHandler(ctx *fasthttp.RequestCtx, data string)
Types ¶
type CreatorFunc ¶
CreatorFunc define func of HandlerCreator
type HandlerCreator ¶
type HandlerCreator struct { MethodPrefix string Creator CreatorFunc }
func (HandlerCreator) New ¶
New common creator Method spec:
(rcvr *XXXX) YYYY(ctx jet.Ctx, req ZZZZ) (err error) (rcvr *XXXX) YYYY(ctx jet.Ctx, req ZZZZ) (ret RRRR, err error) (rcvr *XXXX) YYYY(ctx jet.Ctx, req ZZZZ) (rcvr *XXXX) YYYY(ctx jet.Ctx, req ZZZZ) (ret RRRR, err error) (rcvr *XXXX) YYYY(ctx jet.Ctx, req ZZZZ) (err error) (rcvr *XXXX) YYYY(ctx jet.Ctx) (err error) (rcvr *XXXX) YYYY(ctx jet.Ctx) (ret RRRR, err error) (rcvr *XXXX) YYYY() (err error) (rcvr *XXXX) YYYY() (ret RRRR, err error)
type HandlerFactory ¶
type HandlerFactory map[string]CreatorFunc
func (HandlerFactory) RegisterFactory ¶
func (factory HandlerFactory) RegisterFactory(prefix string, newFactoryFunc creatorRegisterFunc)
RegisterFactory You can replace the default factory implementation, but you must bear the risk for this. Calmly, you can also add new factories to implement your own processing logic.
You can enhance the default factory or do some pre- or post-processing, like before- or after-RegisterHook.
Click to show internal directories.
Click to hide internal directories.