MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / doRewrite

Method doRewrite

internal/nodes/http_request_rewrite.go:9–43  ·  view source on GitHub ↗

调用Rewrite

()

Source from the content-addressed store, hash-verified

7
8// 调用Rewrite
9func (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}

Callers 1

doBeginMethod · 0.95

Calls 4

doURLMethod · 0.95
httpRedirectFunction · 0.85
HeaderMethod · 0.45

Tested by

no test coverage detected