Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 753 Bytes

redirects.md

File metadata and controls

32 lines (26 loc) · 753 Bytes
title draft
리디렉션
false

HTTP 리다이렉트 하는 것은 간단합니다. 내부와 외부위치를 모두 지원합니다.

r.GET("/test", func(c *gin.Context) {
	c.Redirect(http.StatusMovedPermanently, "http://www.google.com/")
})

Issuing a HTTP redirect from POST. Refer to issue: #444

r.POST("/test", func(c *gin.Context) {
	c.Redirect(http.StatusFound, "/foo")
})

라우터 리다이렉트를 실행하려면, 아래와 같이 HandleContext를 사용하세요.

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"})
})