partial bug fix
This commit is contained in:
committed by
Violet Ash
parent
a79e6ce975
commit
8c8652ce67
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user