From 7f53288b378fc3bd5d300c1131a0fe5ddea76e5f Mon Sep 17 00:00:00 2001 From: CornierKhan1 Date: Sat, 10 Nov 2018 14:07:15 +1100 Subject: [PATCH] *pulls config card* --- core.go | 16 ---------------- main.go | 20 ++++++++++++++------ 2 files changed, 14 insertions(+), 22 deletions(-) delete mode 100644 core.go diff --git a/core.go b/core.go deleted file mode 100644 index 0ae5ba5..0000000 --- a/core.go +++ /dev/null @@ -1,16 +0,0 @@ -package main - -import ( - "database/sql" - _ "github.com/go-sql-driver/mysql" - "log" -) - -func StartSQL() { - db, err := sql.Open("mysql", - ":"+"@tcp(127.0.0.1:3306)/hello") - if err != nil { - log.Fatal(err) - } - defer db.Close() -} diff --git a/main.go b/main.go index e44724b..eece325 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,7 @@ package main import ( "bytes" + "database/sql" "encoding/xml" "fmt" _ "github.com/go-sql-driver/mysql" @@ -46,23 +47,30 @@ func CheckError(e error) { func main() { - fmt.Println("WiiSOAP 0.2 Kawauso") + fmt.Println("WiiSOAP 0.2.1 Kawauso") fmt.Println("Reading the Config...") configfile, err := os.Open("./config.xml") CheckError(err) ioconfig, err := ioutil.ReadAll(configfile) CheckError(err) - Config := Config{} - err = xml.Unmarshal([]byte(ioconfig), &Config) - fmt.Println(Config) + CON := Config{} + err = xml.Unmarshal([]byte(ioconfig), &CON) + fmt.Println(CON) CheckError(err) + fmt.Println("Initializing core...") - fmt.Println("Starting HTTP connection (Port 2018)...") + // Start SQL. + db, err := sql.Open("mysql", + CON.SQLUser+":"+CON.SQLPass+"@tcp(127.0.0.1:3306)/hello") + CheckError(err) + defer db.Close() + + fmt.Println("Starting HTTP connection (" + CON.Port + ")...") fmt.Println("NOTICE: The SOAP Server runs under a port that doesn't work with WSC naturally.") fmt.Println("You can either use proxying from Nginx (recommended) or another web server software, or edit this script to use port 80.") http.HandleFunc("/", handler) // each request calls handler - log.Fatal(http.ListenAndServe(":2018", nil)) + log.Fatal(http.ListenAndServe(CON.Port, nil)) } func handler(w http.ResponseWriter, r *http.Request) {