From d69e4e8fc468611d232465c0e3db0e683bc205cf Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Wed, 10 Nov 2021 10:25:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E6=94=B6=E8=AF=B7=E6=B1=82=E6=97=B6?= =?UTF-8?q?=E4=BF=9D=E7=95=99URL=E8=B7=AF=E5=BE=84=E4=B8=AD=E5=A4=9A?= =?UTF-8?q?=E4=BA=8E=E7=9A=84=E6=96=9C=E6=9D=A0=EF=BC=88/=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/listener_http.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/internal/nodes/listener_http.go b/internal/nodes/listener_http.go index 0882ffe..bfef438 100644 --- a/internal/nodes/listener_http.go +++ b/internal/nodes/listener_http.go @@ -37,18 +37,13 @@ type HTTPListener struct { } func (this *HTTPListener) Serve() error { - handler := http.NewServeMux() - handler.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) { - this.handleHTTP(writer, request) - }) - this.addr = this.Group.Addr() this.isHTTP = this.Group.IsHTTP() this.isHTTPS = this.Group.IsHTTPS() this.httpServer = &http.Server{ Addr: this.addr, - Handler: handler, + Handler: this, ReadHeaderTimeout: 2 * time.Second, // TODO 改成可以配置 IdleTimeout: 2 * time.Minute, // TODO 改成可以配置 ErrorLog: httpErrorLogger, @@ -118,8 +113,8 @@ func (this *HTTPListener) Reload(group *serverconfigs.ServerAddressGroup) { this.Reset() } -// 处理HTTP请求 -func (this *HTTPListener) handleHTTP(rawWriter http.ResponseWriter, rawReq *http.Request) { +// ServerHTTP 处理HTTP请求 +func (this *HTTPListener) ServeHTTP(rawWriter http.ResponseWriter, rawReq *http.Request) { // 域名 reqHost := rawReq.Host