Filled in more of the templates...

This commit is contained in:
CornierKhan1 2018-09-06 16:38:06 +10:00
parent 6ed1f051c2
commit eb65089272

60
main.go
View File

@ -54,6 +54,7 @@ type NETS struct {
DeviceId string `xml:"Body>NotifiedETicketsSynced>DeviceId"`
MessageId string `xml:"Body>NotifiedETicketsSynced>MessageId"`
}
// ListETickets
type LET struct {
XMLName xml.Name `xml:"Envelope"`
@ -61,6 +62,7 @@ type LET struct {
DeviceId string `xml:"Body>ListETickets>DeviceId"`
MessageId string `xml:"Body>ListETickets>MessageId"`
}
// PurchaseTitle
type PT struct {
XMLName xml.Name `xml:"Envelope"`
@ -68,6 +70,7 @@ type PT struct {
DeviceId string `xml:"Body>PurchaseTitle>DeviceId"`
MessageId string `xml:"Body>PurchaseTitle>MessageId"`
}
// CheckRegistration
type CR struct {
XMLName xml.Name `xml:"Envelope"`
@ -75,6 +78,7 @@ type CR struct {
DeviceId string `xml:"Body>CheckRegistration>DeviceId"`
MessageId string `xml:"Body>CheckRegistration>MessageId"`
}
// GetRegistrationInfo
type GRI struct {
XMLName xml.Name `xml:"Envelope"`
@ -83,6 +87,14 @@ type GRI struct {
MessageId string `xml:"Body>GetRegistrationInfo>MessageId"`
}
// Register
type REG struct {
}
// Unregister
type UNR struct {
}
func main() {
fmt.Println("Starting HTTP connection (Port 8000)...")
http.HandleFunc("/", handler) // each request calls handler
@ -252,18 +264,66 @@ func handler(w http.ResponseWriter, r *http.Request) {
// IDENTITY AUTHENTICATION SOAP
if bytes.Contains(body, []byte("CheckRegistration")) {
fmt.Println("CR.")
CR := CR{}
err = xml.Unmarshal([]byte(body), &CR)
if err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
fmt.Fprint(w, "not good enough for me. ;)")
fmt.Printf("error: %v", err)
return
}
fmt.Println(CR)
fmt.Println("The request is valid! Responding...")
fmt.Fprintf(w, ``)
} else {
if bytes.Contains(body, []byte("GetRegistrationInfo")) {
fmt.Println("GRI.")
GRI := GRI{}
err = xml.Unmarshal([]byte(body), &GRI)
if err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
fmt.Fprint(w, "how dirty. ;)")
fmt.Printf("error: %v", err)
return
}
fmt.Println(GRI)
fmt.Println("The request is valid! Responding...")
fmt.Fprintf(w, ``)
} else {
if bytes.Contains(body, []byte("Register")) {
fmt.Println("REG.")
REG := REG{}
err = xml.Unmarshal([]byte(body), &REG)
if err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
fmt.Fprint(w, "disgustingly invalid. ;)")
fmt.Printf("error: %v", err)
return
}
fmt.Println(REG)
fmt.Println("The request is valid! Responding...")
fmt.Fprintf(w, ``)
} else {
if bytes.Contains(body, []byte("Unregister")) {
fmt.Println("UNR.")
UNR := UNR{}
err = xml.Unmarshal([]byte(body), &UNR)
if err != nil {
fmt.Println("...or not. Bad or incomplete request. (End processing.)")
fmt.Fprint(w, "how abnormal... ;)")
fmt.Printf("error: %v", err)
return
}
fmt.Println(UNR)
fmt.Println("The request is valid! Responding...")
fmt.Fprintf(w, ``)
} else {
fmt.Println("Nothing sent?")