From 4d9ea86e8c6f16f92d5235cb11ad456bbc19c2f8 Mon Sep 17 00:00:00 2001 From: youjianglong Date: Tue, 20 Mar 2018 15:38:31 +0800 Subject: [PATCH] =?UTF-8?q?Tango=20struct=E5=A2=9E=E5=8A=A0http.Server?= =?UTF-8?q?=E6=88=90=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tan.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tan.go b/tan.go index 8b04665..c2e0ef9 100644 --- a/tan.go +++ b/tan.go @@ -19,6 +19,7 @@ func Version() string { // Tango describes tango object type Tango struct { + http.Server Router handlers []Handler logger Logger @@ -146,7 +147,10 @@ func (t *Tango) Run(args ...interface{}) { addr := getAddress(args...) t.logger.Info("Listening on http://" + addr) - err := http.ListenAndServe(addr, t) + t.Server.Addr = addr + t.Server.Handler = t + + err := t.ListenAndServe() if err != nil { t.logger.Error(err) } @@ -158,7 +162,10 @@ func (t *Tango) RunTLS(certFile, keyFile string, args ...interface{}) { t.logger.Info("Listening on https://" + addr) - err := http.ListenAndServeTLS(addr, certFile, keyFile, t) + t.Server.Addr = addr + t.Server.Handler = t + + err := t.ListenAndServeTLS(certFile, keyFile) if err != nil { t.logger.Error(err) } -- 2.40.1