리디렉션
HTTP 리다이렉트 하는 것은 간단합니다. 내부와 외부위치를 모두 지원합니다.
router.GET("/test", func(c *gin.Context) { c.Redirect(http.StatusMovedPermanently, "http://www.google.com/")})
Issuing a HTTP redirect from POST. Refer to issue: #444
router.POST("/test", func(c *gin.Context) { c.Redirect(http.StatusFound, "/foo")})
라우터 리다이렉트를 실행하려면, 아래와 같이 HandleContext
를 사용하세요.
router.GET("/test", func(c *gin.Context) { c.Request.URL.Path = "/test2" router.HandleContext(c)})router.GET("/test2", func(c *gin.Context) { c.JSON(200, gin.H{"hello": "world"})})