|
|
@@ -1082,14 +1082,26 @@ Gin allow by default use only one html.Template. Check [a multitemplate render](
|
|
|
|
|
|
### Redirects
|
|
|
|
|
|
-Issuing a HTTP redirect is easy:
|
|
|
+Issuing a HTTP redirect is easy. Both internal and external locations are supported.
|
|
|
|
|
|
```go
|
|
|
r.GET("/test", func(c *gin.Context) {
|
|
|
c.Redirect(http.StatusMovedPermanently, "http://www.google.com/")
|
|
|
})
|
|
|
```
|
|
|
-Both internal and external locations are supported.
|
|
|
+
|
|
|
+
|
|
|
+Issuing a Router redirect, use `HandleContext` like below.
|
|
|
+
|
|
|
+``` go
|
|
|
+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"})
|
|
|
+})
|
|
|
+```
|
|
|
|
|
|
|
|
|
### Custom Middleware
|