diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..232cf25 Binary files /dev/null and b/.DS_Store differ diff --git a/implementations/.DS_Store b/implementations/.DS_Store new file mode 100644 index 0000000..3ef8c14 Binary files /dev/null and b/implementations/.DS_Store differ diff --git a/implementations/go/.DS_Store b/implementations/go/.DS_Store new file mode 100644 index 0000000..a1c3521 Binary files /dev/null and b/implementations/go/.DS_Store differ diff --git a/implementations/go/.gitignore b/implementations/go/.gitignore new file mode 100644 index 0000000..8202dec --- /dev/null +++ b/implementations/go/.gitignore @@ -0,0 +1 @@ +./ngrok \ No newline at end of file diff --git a/implementations/go/README.md b/implementations/go/README.md index 7d422fb..81d173e 100644 --- a/implementations/go/README.md +++ b/implementations/go/README.md @@ -1,5 +1,10 @@ # Soccergist - Go +Install go-lang on your system http://golang.org + + + ## Contributors -* Oscar \ No newline at end of file +* Oscar +* LordRahl90 http://github.com/LordRahl90 \ No newline at end of file diff --git a/implementations/go/handlers/baseHandler.go b/implementations/go/handlers/baseHandler.go new file mode 100644 index 0000000..b0944bd --- /dev/null +++ b/implementations/go/handlers/baseHandler.go @@ -0,0 +1,11 @@ +package handlers + +import ( + "fmt" + "net/http" +) + +//HomeHandler - function to handle lading page routes +func HomeHandler(w http.ResponseWriter, r *http.Request) { + fmt.Fprint(w, "welcome to the movie guide bot challenge") +} diff --git a/implementations/go/handlers/botHandler.go b/implementations/go/handlers/botHandler.go new file mode 100644 index 0000000..07c0add --- /dev/null +++ b/implementations/go/handlers/botHandler.go @@ -0,0 +1,31 @@ +package handlers + +import ( + "fmt" + "net/http" +) + +//WebHookHandler - function to handler webhooks +func WebHookHandler(w http.ResponseWriter, r *http.Request) { + queryString := r.URL.Query() + + hubMode := queryString.Get("hub.mode") + hubChallenge := queryString.Get("hub.challenge") + hubVerifyToken := queryString.Get("hub.verify_token") + + fmt.Println(hubVerifyToken) + + if hubMode != "subscribe" { + w.WriteHeader(403) + fmt.Fprint(w, "Invalid Mode Discovered!") + return + } + + if hubVerifyToken != "only the strong will continue" { + w.WriteHeader(403) + fmt.Fprint(w, "Invalid/Unhandled token detected") + return + } + + fmt.Fprint(w, hubChallenge) +} diff --git a/implementations/go/main.go b/implementations/go/main.go new file mode 100644 index 0000000..83f0653 --- /dev/null +++ b/implementations/go/main.go @@ -0,0 +1,20 @@ +package main + +import ( + "fmt" + "log" + "net/http" + + "github.com/LordRahl90/botDevelopment/handlers" + "github.com/gorilla/mux" +) + +func main() { + router := mux.NewRouter() + + router.HandleFunc("/", handlers.HomeHandler).Methods("GET") + router.HandleFunc("/webhook", handlers.WebHookHandler).Methods("GET") + + fmt.Println("Server Starting up") + log.Fatal(http.ListenAndServe(":3000", router)) +} diff --git a/implementations/go/ngrok b/implementations/go/ngrok new file mode 100755 index 0000000..f3cf76b Binary files /dev/null and b/implementations/go/ngrok differ diff --git a/implementations/go/router/mainRoute.go b/implementations/go/router/mainRoute.go new file mode 100644 index 0000000..e69de29