Added DB Ping. Updated Structures. Updated Config.

This commit is contained in:
CornierKhan1 2018-12-10 11:34:49 +11:00
parent 260b5d2573
commit 1311fe103c
3 changed files with 12 additions and 3 deletions

View File

@ -1,6 +1,8 @@
<Config>
<SQLUser>uwu</SQLUser>
<SQLPass>owo</SQLPass>
<SQLDB>uwu</SQLDB>
<SQLPort>127.0.0.1:3306</SQLPort>
<Port>127.0.0.1:8080</Port>
<!-- Please use an address for the port. Failing to do so will cause oddities to occur with WiiSOAP. -->
</Config>

View File

@ -64,9 +64,12 @@ func main() {
// Start SQL.
db, err := sql.Open("mysql",
CON.SQLUser+":"+CON.SQLPass+"@tcp(127.0.0.1:3306)/hello")
CON.SQLUser+":"+CON.SQLPass+"@tcp("+CON.SQLPort+")/"+CON.SQLDB)
CheckError(err)
defer db.Close()
err = db.Ping()
CheckError(err)
// Start the HTTP server.
fmt.Println("Starting HTTP connection (" + CON.Port + ")...")
@ -92,7 +95,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
// 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: Make the case functions cleaner. (e.g. 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":

View File

@ -1,6 +1,8 @@
package main
import "encoding/xml"
import (
"encoding/xml"
)
// Copyright (C) 2018 CornierKhan1
//
@ -28,7 +30,9 @@ type Config struct {
XMLName xml.Name `xml:"Config"`
SQLUser string `xml:"SQLUser"`
SQLPass string `xml:"SQLPass"`
SQLPort string `xml:"SQLPort"`
Port string `xml:"Port"`
SQLDB string `xml:"SQLDB"`
}
// CheckDeviceStatus