*pulls config card*

This commit is contained in:
CornierKhan1 2018-11-10 14:07:15 +11:00
parent 0bc9b8026b
commit 7f53288b37
2 changed files with 14 additions and 22 deletions

16
core.go
View File

@ -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()
}

20
main.go
View File

@ -19,6 +19,7 @@ package main
import ( import (
"bytes" "bytes"
"database/sql"
"encoding/xml" "encoding/xml"
"fmt" "fmt"
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
@ -46,23 +47,30 @@ func CheckError(e error) {
func main() { func main() {
fmt.Println("WiiSOAP 0.2 Kawauso") fmt.Println("WiiSOAP 0.2.1 Kawauso")
fmt.Println("Reading the Config...") fmt.Println("Reading the Config...")
configfile, err := os.Open("./config.xml") configfile, err := os.Open("./config.xml")
CheckError(err) CheckError(err)
ioconfig, err := ioutil.ReadAll(configfile) ioconfig, err := ioutil.ReadAll(configfile)
CheckError(err) CheckError(err)
Config := Config{} CON := Config{}
err = xml.Unmarshal([]byte(ioconfig), &Config) err = xml.Unmarshal([]byte(ioconfig), &CON)
fmt.Println(Config) fmt.Println(CON)
CheckError(err) CheckError(err)
fmt.Println("Initializing core...") 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("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.") 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 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) { func handler(w http.ResponseWriter, r *http.Request) {