Use routing groups in gin

package main
 
import (
    "github.com/gin-gonic/gin"
)
 
func main() {
    router := gin.Default()
 
    // 后台路由
    admin := router.Group("/admin")
    admin.GET("/t1", func(context *gin.Context) {
        context.String(200, "/admin/t1")
    })
 
    // 前台路由
    front := router.Group("/")
    front.GET("/t2", func(context *gin.Context) {
        context.String(200, "/t2")
    })
 
    router.Run()
}

Leave a Reply

Your email address will not be published. Required fields are marked *

en_USEnglish