From cd3793fb0c00a579e08650c5abf347fbb5810911 Mon Sep 17 00:00:00 2001 From: amatsagu Date: Sun, 10 Dec 2023 17:55:24 +0100 Subject: [PATCH] fix: use custom http server when starting instead default --- client.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index f85d1ea..6cde46a 100644 --- a/client.go +++ b/client.go @@ -152,8 +152,9 @@ func (client *Client) ListenAndServe(route string, address string) error { client.state.Store(uint32(RUNNING_STATE)) client.httpServeMux.HandleFunc(route, client.handleRequest) + client.httpServer.(*http.Server).Addr = address client.httpServer.(*http.Server).Handler = client.httpServeMux - return http.ListenAndServe(address, nil) + return client.httpServer.ListenAndServe() } func (client *Client) ListenAndServeTLS(route string, address string, certFile, keyFile string) error { @@ -167,8 +168,9 @@ func (client *Client) ListenAndServeTLS(route string, address string, certFile, client.state.Store(uint32(RUNNING_STATE)) client.httpServeMux.HandleFunc(route, client.handleRequest) + client.httpServer.(*http.Server).Addr = address client.httpServer.(*http.Server).Handler = client.httpServeMux - return http.ListenAndServeTLS(address, certFile, keyFile, nil) + return client.httpServer.ListenAndServeTLS(certFile, keyFile) } // Tries to gracefully shutdown client. It'll clear all queued actions and shutdown underlying http server.