From 04852cdf584b8108bfcaf52940e7844ea710ec4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ken-H=C3=A5vard=20Lieng?= Date: Fri, 9 Nov 2018 07:32:47 +0100 Subject: [PATCH] Implement http.Handler in server.Dispatch --- server/server.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/server.go b/server/server.go index 5cb461a0..d51c0276 100644 --- a/server/server.go +++ b/server/server.go @@ -119,7 +119,7 @@ func (d *Dispatch) startHTTP() { server := &http.Server{ Addr: net.JoinHostPort(addr, portHTTPS), - Handler: http.HandlerFunc(d.serve), + Handler: d, } if certExists() { @@ -156,11 +156,11 @@ func (d *Dispatch) startHTTP() { port = "1337" } log.Println("[HTTP] Listening on port", port) - log.Fatal(http.ListenAndServe(net.JoinHostPort(addr, port), http.HandlerFunc(d.serve))) + log.Fatal(http.ListenAndServe(net.JoinHostPort(addr, port), d)) } } -func (d *Dispatch) serve(w http.ResponseWriter, r *http.Request) { +func (d *Dispatch) ServeHTTP(w http.ResponseWriter, r *http.Request) { if r.Method != "GET" { fail(w, http.StatusNotFound) return