Created
July 29, 2015 03:48
-
-
Save jabgibson/3b34cd80f57cf97653c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
// "encoding/json" | |
"fmt" | |
"github.com/gorilla/mux" | |
"io/ioutil" | |
"net/http" | |
// "strings" | |
"strings" | |
"time" | |
) | |
func main() { | |
r := mux.NewRouter() | |
r.HandleFunc("/api/x/gobot", gobotHandler) | |
http.Handle("/", r) | |
http.ListenAndServe(":45777", nil) | |
} | |
func gobotHandler(w http.ResponseWriter, r *http.Request) { | |
payload, err := ioutil.ReadAll(r.Body) | |
if err != nil { | |
fmt.Println(err) | |
} | |
boom := parse(string(payload)) | |
for _, x := range boom { | |
fmt.Println(x) | |
} | |
fmt.Println(string(payload)) | |
time.Sleep(time.Second * 10) | |
w.Write([]byte("{\"text\": \"@jab Slay not he that cannot hear. Be thankful ye that hath an ear\"}")) | |
} | |
type SlackData struct { | |
Token string | |
} | |
func parse(payload string) (props []string) { | |
props = strings.Split(payload, "&") | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment