美文网首页
系统资源及路由配置

系统资源及路由配置

作者: funcx | 来源:发表于2019-08-15 11:09 被阅读0次
    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...)
    }
    

    相关文章

      网友评论

          本文标题:系统资源及路由配置

          本文链接:https://www.haomeiwen.com/subject/lnwajctx.html