about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-02-09 19:04:02 +0100
committerEmile <hanemile@protonmail.com>2019-02-09 19:04:02 +0100
commitb9dd27166b0b05624a8f8cf86d54e46188955f27 (patch)
tree062740f4df4b479be5a46ca649ec19cc81ae66d8
parentb423441909994423325eabeff118037d55a5cd77 (diff)
defined the db connection globally and set the max amount of open conns
-rw-r--r--main.go8
1 files changed, 8 insertions, 0 deletions
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))
 }