From 5028ca8247da73a6200840deae7a38d7bac08ace Mon Sep 17 00:00:00 2001 From: CornierKhan1 Date: Thu, 6 Dec 2018 09:55:40 +1100 Subject: [PATCH] added some tidbits. --- config.xml | 1 + main.go | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/config.xml b/config.xml index 9976a76..b33ffbd 100644 --- a/config.xml +++ b/config.xml @@ -2,4 +2,5 @@ uwu owo nou + \ No newline at end of file diff --git a/main.go b/main.go index 779017f..8d40662 100644 --- a/main.go +++ b/main.go @@ -40,14 +40,17 @@ const ( // CheckError makes error handling not as ugly and inefficient. func CheckError(e error) { if e != nil { - log.Fatal("There has been an error while performing this action. Reason: ", e) + log.Fatal("WiiSOAP forgot how to drive and crashed! Reason: ", e) } } func main() { + // Initial Start. fmt.Println("WiiSOAP 0.2.2 Kawauso") fmt.Println("Reading the Config...") + + // Check the Config. configfile, err := os.Open("./config.xml") CheckError(err) ioconfig, err := ioutil.ReadAll(configfile) @@ -65,11 +68,13 @@ func main() { CheckError(err) defer db.Close() + // Start the HTTP server. 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.") + fmt.Println("Not using the usual port for HTTP? Be sure to use a proxy, otherwise the Wii can't connect!") http.HandleFunc("/", handler) // each request calls handler log.Fatal(http.ListenAndServe(CON.Port, nil)) + + // From here on out, all special cool things should go into the handler function. } func handler(w http.ResponseWriter, r *http.Request) { @@ -85,9 +90,10 @@ func handler(w http.ResponseWriter, r *http.Request) { http.StatusInternalServerError) } - // The requests are in byte format, so please use []byte("") when adding a new case. + // The switch converts the HTTP Body of the request into a string. There is no need to convert the cases to byte format. switch string(body) { // TODO: Make the case functions cleaner. (e.g. The should the response be a variable?) + // TODO: Update the responses so that they query the SQL Database for the proper information (e.g. Device Code, Token, etc). case "CheckDeviceStatus": @@ -97,7 +103,6 @@ func handler(w http.ResponseWriter, r *http.Request) { if err != nil { fmt.Println("...or not. Bad or incomplete request. (End processing.)") fmt.Fprint(w, "You need to POST some SOAP from WSC if you wanna get some, honey. ;)") - fmt.Printf("error: %v", err) return } fmt.Println(CDS)