package main
import (
"log"
"github.com/gin-gonic/gin"
)
func main() {
engin := gin.Default()
router := Engin(engin)
router("学生", "查询", "/student", func(ctx *gin.Context) {
ctx.String(200, "hah")
})
router("学生1", "查询1", "/student1", func(ctx *gin.Context) {
ctx.String(200, "hah")
})
engin.Run(":9000")
}
func Engin(router *gin.Engine) func(resName, oper, relativePath string, handlers ...gin.HandlerFunc) {
return func(resName, oper, relativePath string, handlers ...gin.HandlerFunc) {
IniHandle(router, relativePath, handlers...)
IniResource(resName, oper, relativePath)
}
}
// 配置系统资源
func IniResource(resName, oper, relativePath string) {
log.Println("系统资源:", resName, oper, relativePath)
}
// 配置和资源操作
func IniHandle(engin *gin.Engine, relativePath string, handlers ...gin.HandlerFunc) {
engin.POST(relativePath, handlers...)
}
网友评论