Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added implementations/.DS_Store
Binary file not shown.
Binary file added implementations/go/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions implementations/go/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./ngrok
7 changes: 6 additions & 1 deletion implementations/go/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Soccergist - Go

Install go-lang on your system http://golang.org




## Contributors
* Oscar
* Oscar
* LordRahl90 http://github.com/LordRahl90
11 changes: 11 additions & 0 deletions implementations/go/handlers/baseHandler.go
Original file line number Diff line number Diff line change
@@ -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")
}
31 changes: 31 additions & 0 deletions implementations/go/handlers/botHandler.go
Original file line number Diff line number Diff line change
@@ -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)
}
20 changes: 20 additions & 0 deletions implementations/go/main.go
Original file line number Diff line number Diff line change
@@ -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))
}
Binary file added implementations/go/ngrok
Binary file not shown.
Empty file.