Documentation
¶
Index ¶
- Constants
- func ComposeCustomMappingKey(method string, path string) string
- func RegisterAPIRoute(ginEngine *gin.Engine, controllers []IBaseController)
- func RegisterGroupAPIRoute(basePath string, ginEngine *gin.Engine, controllers []IBaseController)
- func SetLogger(log ILogger)
- type BaseController
- func (t *BaseController) Delete(c *gin.Context)
- func (t *BaseController) Get(c *gin.Context)
- func (t *BaseController) Head(c *gin.Context)
- func (t *BaseController) Mapping() map[string]GinHandler
- func (t *BaseController) Options(c *gin.Context)
- func (t *BaseController) Patch(c *gin.Context)
- func (t *BaseController) Post(c *gin.Context)
- func (t *BaseController) Put(c *gin.Context)
- type GinHandler
- type IBaseController
- type ILogger
Constants ¶
View Source
const ( // ControllerSuffix defin the suffix of controller struct ControllerSuffix = "Controller" // ErrorControllerName is a message of controller wrong name ErrorControllerName = "Controller name must be suffix with 'Controller'" )
View Source
const (
// KeySeperator seperator for keys
KeySeperator = ":"
)
Variables ¶
This section is empty.
Functions ¶
func ComposeCustomMappingKey ¶
ComposeCustomMappingKey which used in custom mapping logic, join the http method and the path into a string. method is http.MethodXXX which defined in http package
func RegisterAPIRoute ¶
func RegisterAPIRoute(ginEngine *gin.Engine, controllers []IBaseController)
RegisterAPIRoute is the main function.use this func can auto register the method to the certain request url
func RegisterGroupAPIRoute ¶
func RegisterGroupAPIRoute(basePath string, ginEngine *gin.Engine, controllers []IBaseController)
RegisterGroupAPIRoute as RegisterAPIRout, the only difference between them is group method can has pre base url
Types ¶
type BaseController ¶
type BaseController struct { }
BaseController implement IBaseController, cover the base functions with 404 response
func (*BaseController) Delete ¶
func (t *BaseController) Delete(c *gin.Context)
Delete default method
func (*BaseController) Mapping ¶
func (t *BaseController) Mapping() map[string]GinHandler
Mapping default method
func (*BaseController) Options ¶
func (t *BaseController) Options(c *gin.Context)
Options default method
type IBaseController ¶
type IBaseController interface { //Get is for the HttpGet route for the certain request Get(c *gin.Context) //Post is for the HttpPost route for the certain request Post(c *gin.Context) //Put is for the HttpPut route for the certain request Put(c *gin.Context) //Delete is for the HttpDelete route for the certain request Delete(c *gin.Context) //Patch is for the HttpPatch route for the certain request Patch(c *gin.Context) //Head is for the HttpHead route for the certain request Head(c *gin.Context) //Options is for the HttpOptions route for the certain request Options(c *gin.Context) //Mapping is the method that mapping custom request to certain method Mapping() map[string]GinHandler }
IBaseController that satisfies restfulrouter.IBaseController can be auto mapping request to the certain method
Click to show internal directories.
Click to hide internal directories.