mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 07:40:56 +08:00 
			
		
		
		
	多个提示页面增加请求ID、增加变量支持
This commit is contained in:
		@@ -11,11 +11,8 @@ func (this *HTTPRequest) write404() {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	this.processResponseHeaders(http.StatusNotFound)
 | 
			
		||||
 | 
			
		||||
	msg := "404 page not found: '" + this.RawURI() + "'"
 | 
			
		||||
 | 
			
		||||
	this.writer.WriteHeader(http.StatusNotFound)
 | 
			
		||||
	_, _ = this.writer.Write([]byte(msg))
 | 
			
		||||
	_, _ = this.writer.Write([]byte("404 page not found: '" + this.requestFullURL() + "'" + " (Request Id: " + this.requestId + ")"))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *HTTPRequest) write50x(err error, statusCode int) {
 | 
			
		||||
@@ -28,5 +25,5 @@ func (this *HTTPRequest) write50x(err error, statusCode int) {
 | 
			
		||||
	}
 | 
			
		||||
	this.processResponseHeaders(statusCode)
 | 
			
		||||
	this.writer.WriteHeader(statusCode)
 | 
			
		||||
	_, _ = this.writer.Write([]byte(types.String(statusCode) + " " + http.StatusText(statusCode)))
 | 
			
		||||
	_, _ = this.writer.Write([]byte(types.String(statusCode) + " " + http.StatusText(statusCode) + " (Request Id: " + this.requestId + ")"))
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -88,6 +88,12 @@ func (this *HTTPRequest) doPage(status int) (shouldStop bool) {
 | 
			
		||||
 | 
			
		||||
				return true
 | 
			
		||||
			} else if page.BodyType == shared.BodyTypeHTML {
 | 
			
		||||
				// 这里需要实现设置Status,因为在Format()中可以获取${status}等变量
 | 
			
		||||
				if page.NewStatus > 0 {
 | 
			
		||||
					this.writer.statusCode = page.NewStatus
 | 
			
		||||
				} else {
 | 
			
		||||
					this.writer.statusCode = status
 | 
			
		||||
				}
 | 
			
		||||
				var content = this.Format(page.Body)
 | 
			
		||||
 | 
			
		||||
				// 修改状态码
 | 
			
		||||
 
 | 
			
		||||
@@ -15,5 +15,5 @@ func (this *HTTPRequest) doPlanExpires() {
 | 
			
		||||
	this.processResponseHeaders(statusCode)
 | 
			
		||||
 | 
			
		||||
	this.writer.WriteHeader(statusCode)
 | 
			
		||||
	_, _ = this.writer.WriteString(serverconfigs.DefaultPlanExpireNoticePageBody)
 | 
			
		||||
	_, _ = this.writer.WriteString(this.Format(serverconfigs.DefaultPlanExpireNoticePageBody))
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -224,8 +224,6 @@ func (this *HTTPRequest) doReverseProxy() {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// TODO 清除源站错误次数
 | 
			
		||||
 | 
			
		||||
	// 特殊页面
 | 
			
		||||
	if len(this.web.Pages) > 0 && this.doPage(resp.StatusCode) {
 | 
			
		||||
		err = resp.Body.Close()
 | 
			
		||||
 
 | 
			
		||||
@@ -17,8 +17,8 @@ func (this *HTTPRequest) doTrafficLimit() {
 | 
			
		||||
 | 
			
		||||
	this.writer.WriteHeader(statusCode)
 | 
			
		||||
	if len(config.NoticePageBody) != 0 {
 | 
			
		||||
		_, _ = this.writer.WriteString(config.NoticePageBody)
 | 
			
		||||
		_, _ = this.writer.WriteString(this.Format(config.NoticePageBody))
 | 
			
		||||
	} else {
 | 
			
		||||
		_, _ = this.writer.WriteString(serverconfigs.DefaultTrafficLimitNoticePageBody)
 | 
			
		||||
		_, _ = this.writer.WriteString(this.Format(serverconfigs.DefaultTrafficLimitNoticePageBody))
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user