mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 10:41:03 +01:00
Fix an old issue https://github.com/kataras/iris/issues/355
This commit is contained in:
parent
163817bec4
commit
619a54a9f2
|
@ -2,6 +2,10 @@
|
|||
|
||||
**How to upgrade**: remove your `$GOPATH/src/github.com/kataras` folder, open your command-line and execute this command: `go get -u github.com/kataras/iris/iris`.
|
||||
|
||||
## 5.0.2 -> 5.0.3
|
||||
|
||||
- Fix `https relative redirect paths`, a very old issue, which I just saw, peaceful, again :)
|
||||
|
||||
## 5.0.1 -> 5.0.2
|
||||
|
||||
- [geekypanda/httpcache](https://github.com/geekypanda/httpcache) has been re-written,
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<br/>
|
||||
|
||||
|
||||
<a href="https://github.com/kataras/iris/releases"><img src="https://img.shields.io/badge/%20version%20-%205.0.2%20-blue.svg?style=flat-square" alt="Releases"></a>
|
||||
<a href="https://github.com/kataras/iris/releases"><img src="https://img.shields.io/badge/%20version%20-%205.0.3%20-blue.svg?style=flat-square" alt="Releases"></a>
|
||||
|
||||
<a href="https://github.com/iris-contrib/examples"><img src="https://img.shields.io/badge/%20examples-repository-3362c2.svg?style=flat-square" alt="Examples"></a>
|
||||
|
||||
|
@ -825,7 +825,7 @@ I recommend writing your API tests using this new library, [httpexpect](https://
|
|||
Versioning
|
||||
------------
|
||||
|
||||
Current: **v5.0.2**
|
||||
Current: **v5.0.3**
|
||||
|
||||
Stable: **[v4 LTS](https://github.com/kataras/iris/tree/4.0.0#versioning)**
|
||||
|
||||
|
|
33
context.go
33
context.go
|
@ -474,28 +474,29 @@ func (ctx *Context) SetHeader(k string, v string) {
|
|||
// Redirect redirect sends a redirect response the client
|
||||
// accepts 2 parameters string and an optional int
|
||||
// first parameter is the url to redirect
|
||||
// second parameter is the http status should send, default is 302 (StatusFound), you can set it to 301 (Permant redirect), if that's nessecery
|
||||
// second parameter is the http status should send, default is 302 (StatusFound),
|
||||
// you can set it to 301 (Permant redirect), if that's nessecery
|
||||
func (ctx *Context) Redirect(urlToRedirect string, statusHeader ...int) {
|
||||
ctx.StopExecution()
|
||||
|
||||
httpStatus := StatusFound // a 'temporary-redirect-like' which works better than for our purpose
|
||||
if statusHeader != nil && len(statusHeader) > 0 && statusHeader[0] > 0 {
|
||||
httpStatus = statusHeader[0]
|
||||
}
|
||||
|
||||
// #355
|
||||
if ctx.IsTLS() {
|
||||
u := fasthttp.AcquireURI()
|
||||
ctx.URI().CopyTo(u)
|
||||
u.SetScheme("https")
|
||||
u.Update(urlToRedirect)
|
||||
ctx.SetHeader("Location", string(u.FullURI()))
|
||||
fasthttp.ReleaseURI(u)
|
||||
ctx.SetStatusCode(httpStatus)
|
||||
return
|
||||
}
|
||||
|
||||
ctx.RequestCtx.Redirect(urlToRedirect, httpStatus)
|
||||
|
||||
/* you can use one of these if you want to customize the redirection:
|
||||
1.
|
||||
u := fasthttp.AcquireURI()
|
||||
ctx.URI().CopyTo(u)
|
||||
u.Update(urlToRedirect)
|
||||
ctx.SetHeader("Location", string(u.FullURI()))
|
||||
fasthttp.ReleaseURI(u)
|
||||
ctx.SetStatusCode(httpStatus)
|
||||
2.
|
||||
ctx.SetHeader("Location", urlToRedirect)
|
||||
ctx.SetStatusCode(httpStatus)
|
||||
*/
|
||||
|
||||
ctx.StopExecution()
|
||||
}
|
||||
|
||||
// RedirectTo does the same thing as Redirect but instead of receiving a uri or path it receives a route name
|
||||
|
|
Loading…
Reference in New Issue
Block a user