func main() {engine := gin.Default()// 跳转到别的网站engine.GET("/hello", func(context *gin.Context) {context.Redirect(http.StatusMovedPermanently, "https://sogo.com")})// 跳转到自己网站的另一个接口engine.GET("/a", func(context *gin.Context) {context.Request.URL.Path = "/b"engine.HandleContext(context)})engine.GET("/b", func(context *gin.Context) {context.JSON(http.StatusOK, "b")})engine.Run("0.0.0.0:5000")}
