From b9dd27166b0b05624a8f8cf86d54e46188955f27 Mon Sep 17 00:00:00 2001 From: Emile Date: Sat, 9 Feb 2019 19:04:02 +0100 Subject: defined the db connection globally and set the max amount of open conns --- main.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/main.go b/main.go index 3c0a345..47ea3f7 100644 --- a/main.go +++ b/main.go @@ -17,6 +17,7 @@ package main import ( + "database/sql" "fmt" "git.darknebu.la/GalaxySimulator/structs" "log" @@ -27,6 +28,10 @@ import ( //"git.darknebu.la/GalaxySimulator/structs" ) +var ( + db *sql.DB +) + func indexHandler(w http.ResponseWriter, r *http.Request) { log.Println("[ ] The indexHandler was accessed") _, _ = fmt.Fprintf(w, indexEndpoint()) @@ -117,6 +122,9 @@ func main() { // //router.HandleFunc("/readdir/{dirname}", readdirHandler).Methods("GET") + db = connectToDB() + db.SetMaxOpenConns(75) + fmt.Println("Database Container up on port 8081") log.Fatal(http.ListenAndServe(":8081", router)) } -- cgit 1.4.1