Skip to content

Instantly share code, notes, and snippets.

@jabgibson
Created July 29, 2015 03:48
Show Gist options
  • Save jabgibson/3b34cd80f57cf97653c8 to your computer and use it in GitHub Desktop.
Save jabgibson/3b34cd80f57cf97653c8 to your computer and use it in GitHub Desktop.
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