Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { sync.Mutex // GinContext - reuse the gin Context. GinContext *gin.Context // ClientContext - context used to call the backend service. ClientContext context.Context // Param - store the requested body data. Param interface{} // ErrCode - custome http code when return the error hints. ErrCode interface{} // Extra - data read from special middleware will be set here. Extra map[string]interface{} // ErrHandle - handle error hints when validate failed. ErrHandle ErrHandle }
Context request context,implementing the *gin.Context
type ErrHandle ¶
type ErrHandle func(ctx *Context, err interface{})
ErrHandle - handle the validator error.
type ErrHandleFuncChain ¶
type ErrHandleFuncChain []ErrHandleFunc
ErrHandleFuncChain - handle function chain.
type Interface ¶
type Interface struct { // SyncHandleFunc - the special middleware to handle the request param in synchronous way // but only excutes after all the AsyncHandleFunc successing,because some // param may rely on result of the asynchronouse handlefuncs. SyncHandleFunc ErrHandleFuncChain // AsyncHandleFunc - the special middleware to handle the request param in asynchronous way. AsyncHandleFunc ErrHandleFuncChain // Path - starts with "/". Path string // Method - one of `POST,GET,DELETE,PUT,HEAD,PATCH`,case insensitive. Method string // Param - requrest params Param interface{} // Handle function that handles the business logic . Handle HandleFunc // ErrHandle ErrHandle ErrHandle }
Interface define the router interface
func NewInterface ¶
NewInterface - create a new Interface instance.
type Option ¶
type Option func(*Options)
Option - optional config the router.
func WithClientContext ¶
WithClientContext - set context used for call the backend services.
func WithErrHandle ¶
WithErrHandle - set error handle for validator.
func WithErrMsgTagPrefix ¶
WithErrMsgTagPrefix - set the errprefix tag which define the error hints.
func WithMiddlerware ¶
func WithMiddlerware(middleware ...gin.HandlerFunc) Option
WithMiddlerware - set the global middleware for this router.
func WithVaidatorV9 ¶
WithVaidatorV9 - set validator v9 supported locale:en,fr,id,ja,nl,pt_BR,tr,zh,zh_tw;default en
Click to show internal directories.
Click to hide internal directories.