Skip to content

Commit

Permalink
fix: use custom http server when starting instead default
Browse files Browse the repository at this point in the history
  • Loading branch information
amatsagu committed Dec 10, 2023
1 parent a7069e1 commit cd3793f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand Down

0 comments on commit cd3793f

Please sign in to comment.