gin/redirect/main.go

16 lines
266 B
Go
Raw Normal View History

2024-09-18 00:04:45 +08:00
package main
import (
"github.com/gin-gonic/gin"
"net/http"
)
func main() {
r := gin.Default()
r.GET("/redirect", func(c *gin.Context) {
//支持内部和外部重定向
c.Redirect(http.StatusMovedPermanently, "http://www.baidu.com")
})
r.Run(":8000")
}