【Gin框架】Gin路由组

package main

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func main() {
	r := gin.Default()
	orderGroup := r.Group("/order")
	{
		orderGroup.GET("/index", func(c *gin.Context) {
			c.JSON(http.StatusOK, gin.H{
				"router": "order/index",
			})
		})
		orderGroup.GET("/detail", func(c *gin.Context) {
			c.JSON(http.StatusOK, gin.H{
				"router": "order/detail",
			})
		})
	}

	r.Run()
}

猜你喜欢

转载自blog.csdn.net/qq2942713658/article/details/112716214