package main
import (
"github.com/gin-gonic/gin"
"net/http"
)
func main() {
r := gin.Default()
r.GET("/test", func(c *gin.Context) {
c.Redirect(http.StatusMovedPermanently,"https://www.baidu.com/s?wd=acwing")
})
r.GET("/index", func(c *gin.Context) {
c.JSON(200,gin.H{
"status":"ok",
})
})
r.GET("/test1", func(c *gin.Context) {
// 指定重定向的URL
c.Request.URL.Path = "/index"
r.HandleContext(c)
})
// 让服务器进行跑起来
r.Run(":9090")
}
gin框架重定向
最新推荐文章于 2024-04-06 21:58:07 发布