Files
Go-StudyExample/example/gin/35-Redirect_test.go
T

26 lines
390 B
Go
Raw Normal View History

/*
* @Author : huangzj
* @Time : 2020/12/8 16:22
* @Description
*/
package gin
import (
"github.com/gin-gonic/gin"
"testing"
)
//重定向
func TestRedirect(t *testing.T) {
r := gin.Default()
r.GET("/test", func(c *gin.Context) {
c.Request.URL.Path = "/test2"
r.HandleContext(c)
})
r.GET("/test2", func(c *gin.Context) {
c.JSON(200, gin.H{"hello": "world"})
})
}