From 17784f045d5256feefc263fc23cace2090cd46ca Mon Sep 17 00:00:00 2001 From: CornierKhan1 Date: Thu, 6 Sep 2018 13:56:04 +1000 Subject: [PATCH] Added some more Structs. --- main.go | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/main.go b/main.go index 0ab1c14..7fcc9f4 100644 --- a/main.go +++ b/main.go @@ -24,6 +24,7 @@ import ( "io/ioutil" "log" "net/http" + "time" ) const ( @@ -60,6 +61,20 @@ type LET struct { DeviceId string `xml:"Body>ListETickets>DeviceId"` MessageId string `xml:"Body>ListETickets>MessageId"` } +// PurchaseTitle +type PT struct { + XMLName xml.Name `xml:"Envelope"` + Version string `xml:"Body>PurchaseTitle>Version"` + DeviceId string `xml:"Body>PurchaseTitle>DeviceId"` + MessageId string `xml:"Body>PurchaseTitle>MessageId"` +} +// CheckRegistration +type CR struct { + XMLName xml.Name `xml:"Envelope"` + Version string `xml:"Body>CheckRegistration>Version"` + DeviceId string `xml:"Body>CheckRegistration>DeviceId"` + MessageId string `xml:"Body>CheckRegistration>MessageId"` +} func main() { fmt.Println("Starting HTTP connection (Port 8000)...") @@ -184,6 +199,46 @@ func handler(w http.ResponseWriter, r *http.Request) { } else { if bytes.Contains(body, []byte("PurchaseTitle")){ + fmt.Println("PT") + PT := PT{} + err = xml.Unmarshal([]byte(body), &PT) + if err != nil { + fmt.Println("...or not. Bad or incomplete request. (End processing.)") + fmt.Fprint(w, "if you wanna fun time, its gonna cost ya extra sweetie. ;)") + fmt.Printf("error: %v", err) + return + } + fmt.Println(PT) + fmt.Println("The request is valid! Responding...") + fmt.Fprintf(w, ` + + + + ` + PT.Version + ` + ` + PT.DeviceId + ` + ` + PT.MessageId + ` + 00000000 + 0 + false + + 2018 + POINTS + + + 00000000 + ` + time.RFC3339 + ` + PURCHGAME + + 00000000 + 00000000 + 00000000 + 00000000 + 00000000 + + +`) } else {