package main
import (
"github.com/gin-gonic/gin"
"net/http"
)
type UserInfo struct {
Username string `form:"username"`
Password string `form:"password"`
}
func main() {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
c.Redirect(http.StatusMovedPermanently, "https://www.baidu.com/")
})
r.GET("/a", func(c *gin.Context) {
// 修改请求的URI
c.Request.URL.Path = "/b"
r.HandleContext(c)
})
r.GET("/b", func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"stataus": "ok",
})
})
r.Run()
}
【Gin框架】Gin重定向
猜你喜欢
转载自blog.csdn.net/qq2942713658/article/details/112714546
今日推荐
周排行