14 lines
468 B
Go
Executable File
14 lines
468 B
Go
Executable File
package utils
|
|
|
|
import "github.com/gin-gonic/gin"
|
|
|
|
func RouterRegister(group *gin.RouterGroup, requestMethods []string, relativePath string, handlers ...gin.HandlerFunc) gin.IRoutes {
|
|
/* 路由注册:一次性给同一个视图方法绑定多种请求方式 */
|
|
/* 可通switch来分发不同的请求 */
|
|
var routers gin.IRoutes
|
|
for _, requestMethod := range requestMethods {
|
|
routers = group.Handle(requestMethod, relativePath, handlers...)
|
|
}
|
|
return routers
|
|
}
|