调用Rewrite
()
| 7 | |
| 8 | // 调用Rewrite |
| 9 | func (this *HTTPRequest) doRewrite() (shouldShop bool) { |
| 10 | if this.rewriteRule == nil { |
| 11 | return |
| 12 | } |
| 13 | |
| 14 | // 代理 |
| 15 | if this.rewriteRule.Mode == serverconfigs.HTTPRewriteModeProxy { |
| 16 | // 外部URL |
| 17 | if this.rewriteIsExternalURL { |
| 18 | host := this.ReqHost |
| 19 | if len(this.rewriteRule.ProxyHost) > 0 { |
| 20 | host = this.rewriteRule.ProxyHost |
| 21 | } |
| 22 | this.doURL(this.RawReq.Method, this.rewriteReplace, host, 0, false) |
| 23 | return true |
| 24 | } |
| 25 | |
| 26 | // 内部URL继续 |
| 27 | return false |
| 28 | } |
| 29 | |
| 30 | // 跳转 |
| 31 | if this.rewriteRule.Mode == serverconfigs.HTTPRewriteModeRedirect { |
| 32 | if this.rewriteRule.RedirectStatus > 0 { |
| 33 | this.ProcessResponseHeaders(this.writer.Header(), this.rewriteRule.RedirectStatus) |
| 34 | httpRedirect(this.writer, this.RawReq, this.rewriteReplace, this.rewriteRule.RedirectStatus) |
| 35 | } else { |
| 36 | this.ProcessResponseHeaders(this.writer.Header(), http.StatusTemporaryRedirect) |
| 37 | httpRedirect(this.writer, this.RawReq, this.rewriteReplace, http.StatusTemporaryRedirect) |
| 38 | } |
| 39 | return true |
| 40 | } |
| 41 | |
| 42 | return true |
| 43 | } |
no test coverage detected