From 5dde5e766c0178a80416e3ec8f3ffc55a2691ed2 Mon Sep 17 00:00:00 2001 From: maride Date: Fri, 7 Sep 2018 14:04:58 +0200 Subject: Cleanup, react to signals (\^C), tidy up and sort code --- src/http.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/http.go') diff --git a/src/http.go b/src/http.go index 91d1c87..d1e3507 100644 --- a/src/http.go +++ b/src/http.go @@ -21,7 +21,7 @@ func registerHTTPFlags() { port = flag.Int("port", 8080, "The port for HTTP") } -func runHTTPServer() (error) { +func setupHTTPServer() (http.Server) { r := mux.NewRouter() r.HandleFunc("/", indexHandler) @@ -37,8 +37,10 @@ func runHTTPServer() (error) { r.HandleFunc("/api/stopContainer", stopContainerHandler).Methods("POST") r.HandleFunc("/api/getAccess", getAccessHandler).Methods("GET") - address := fmt.Sprintf("0.0.0.0:%d", *port) - return http.ListenAndServe(address, r) + return http.Server{ + Addr: fmt.Sprintf("0.0.0.0:%d", *port), + Handler: r, + } } // Host the index file -- cgit 1.4.1