package main

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

func main() {
	r := gin.Default()

	// 单个参数
	r.GET("/users/:id", func(c *gin.Context) {
		id := c.Param("id") // 获取参数
		c.JSON(200, gin.H{"user_id": id})
	})

	// 多个参数
	r.GET("/users/:uid/posts/:pid", func(c *gin.Context) {
		uid := c.Param("uid")
		pid := c.Param("pid")
		c.JSON(200, gin.H{"uid": uid, "pid": pid})
	})

	r.Run(":8080")
}
