diff --git a/backend/src/security-layer/container/authentication.go b/backend/src/security-layer/container/authentication.go index e2a4381..2152d1e 100644 --- a/backend/src/security-layer/container/authentication.go +++ b/backend/src/security-layer/container/authentication.go @@ -208,12 +208,12 @@ func validateHash(decrypted string, hash string) bool { // Authentication takes place solely on the backend. func ServeAuthentication( router *mux.Router, - port int, + port string, ) { // TODO: Add error handling authR := router.Host("http://localhost").Subrouter() authSrv := &http.Server{ - Addr: "0.0.0.0:" + string(port), + Addr: "0.0.0.0:" + port, WriteTimeout: time.Second * 15, ReadTimeout: time.Second * 15, IdleTimeout: time.Second * 60, @@ -226,5 +226,5 @@ func ServeAuthentication( } }() - log.Println("Auth server is running on port " + string(port)) + log.Println("Auth server is running on port " + port) } diff --git a/backend/src/security-layer/container/router.go b/backend/src/security-layer/container/router.go index d8f3952..c8ebe6b 100644 --- a/backend/src/security-layer/container/router.go +++ b/backend/src/security-layer/container/router.go @@ -249,9 +249,9 @@ func serve() { r := mux.NewRouter() //for _, webpage := range config.Webpages { //} - ServePage(r, config.WebpageDir, "/", config.WebpagePort) - ServeApi(r, config.API, endpoint, function, config.APIPort) - ServeAuthentication(r, config.AuthPort) + ServePage(r, config.WebpageDir, "/", string(config.WebpagePort)) + ServeApi(r, config.API, endpoint, function, string(config.APIPort)) + ServeAuthentication(r, string(config.AuthPort)) addr := "0.0.0.0:" + string(config.RouterPort) srv := &http.Server{ diff --git a/backend/src/security-layer/container/serveAPI.go b/backend/src/security-layer/container/serveAPI.go index 61ca8e6..1e825f2 100644 --- a/backend/src/security-layer/container/serveAPI.go +++ b/backend/src/security-layer/container/serveAPI.go @@ -15,7 +15,7 @@ func ServeApi( domain string, endpoint []string, function []func(http.ResponseWriter, *http.Request), - port int, + port string, ) { // TODO: Add error handling apiR := router.Host(domain).Subrouter() @@ -25,7 +25,7 @@ func ServeApi( } apiSrv := &http.Server{ - Addr: "0.0.0.0:" + string(port), + Addr: "0.0.0.0:" + port, WriteTimeout: time.Second * 15, ReadTimeout: time.Second * 15, IdleTimeout: time.Second * 60, @@ -38,5 +38,5 @@ func ServeApi( } }() - log.Println("API server is running on port " + string(port)) + log.Println("API server is running on port " + port) } diff --git a/backend/src/security-layer/container/servePage.go b/backend/src/security-layer/container/servePage.go index cc9dbfb..708511d 100644 --- a/backend/src/security-layer/container/servePage.go +++ b/backend/src/security-layer/container/servePage.go @@ -8,11 +8,11 @@ import ( ) // Serve a directory to a port. -func ServePage(router *mux.Router, dest string, path string, port int) { +func ServePage(router *mux.Router, dest string, path string, port string) { router.PathPrefix(path).Handler(http.FileServer(http.Dir(dest))) srv := &http.Server{ - Addr: "0.0.0.0: " + string(port), + Addr: "0.0.0.0: " + port, // Good practice to set timeouts to avoid Slowloris attacks. WriteTimeout: time.Second * 15, ReadTimeout: time.Second * 15, @@ -27,5 +27,5 @@ func ServePage(router *mux.Router, dest string, path string, port int) { } }() - log.Println("Web server is running on port " + string(port)) + log.Println("Web server is running on port " + port) }