Do 执行请求
()
| 148 | |
| 149 | // Do 执行请求 |
| 150 | func (this *HTTPRequest) Do() { |
| 151 | // 初始化 |
| 152 | this.init() |
| 153 | |
| 154 | // 当前服务的反向代理配置 |
| 155 | if this.ReqServer.ReverseProxyRef != nil && this.ReqServer.ReverseProxy != nil { |
| 156 | this.reverseProxyRef = this.ReqServer.ReverseProxyRef |
| 157 | this.reverseProxy = this.ReqServer.ReverseProxy |
| 158 | } |
| 159 | |
| 160 | // Web配置 |
| 161 | err := this.configureWeb(this.ReqServer.Web, true, 0) |
| 162 | if err != nil { |
| 163 | this.write50x(err, http.StatusInternalServerError, "Failed to configure the server", "配置服务失败", false) |
| 164 | this.doEnd() |
| 165 | return |
| 166 | } |
| 167 | |
| 168 | // 是否为低级别节点 |
| 169 | this.isLnRequest = this.checkLnRequest() |
| 170 | |
| 171 | // 回调事件 |
| 172 | this.onInit() |
| 173 | if this.writer.isFinished { |
| 174 | this.doEnd() |
| 175 | return |
| 176 | } |
| 177 | |
| 178 | // 处理健康检查 |
| 179 | var healthCheckKey = this.RawReq.Header.Get(serverconfigs.HealthCheckHeaderName) |
| 180 | if len(healthCheckKey) > 0 { |
| 181 | if this.doHealthCheck(healthCheckKey, &this.isHealthCheck) { |
| 182 | this.doEnd() |
| 183 | return |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | if !this.isLnRequest { |
| 188 | // 特殊URL处理 |
| 189 | if len(this.rawURI) > 1 && this.rawURI[1] == '.' { |
| 190 | // ACME |
| 191 | // TODO 需要配置是否启用ACME检测 |
| 192 | if strings.HasPrefix(this.rawURI, "/.well-known/acme-challenge/") { |
| 193 | if this.doACME() { |
| 194 | this.doEnd() |
| 195 | return |
| 196 | } |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | // 套餐 |
| 201 | if this.ReqServer.UserPlan != nil { |
| 202 | if this.doPlanBefore() { |
| 203 | this.doEnd() |
| 204 | return |
| 205 | } |
| 206 | } |
| 207 |