Skip to content

Instantly share code, notes, and snippets.

@bash0C7
Created November 9, 2013 09:32
Show Gist options
  • Save bash0C7/7383655 to your computer and use it in GitHub Desktop.
Save bash0C7/7383655 to your computer and use it in GitHub Desktop.
Idobata General Webhook Client (golang)
package main
import "net/http"
import "net/url"
import "os"
import "fmt"
import "flag"
import "io/ioutil"
func main() {
var webhook_url = os.Getenv("URL")
format := func() string {
f := ""
flag.StringVar(&f, "format", "html", "html or json")
flag.Parse()
return f
}()
source := func() string {
bytes, err := ioutil.ReadAll(os.Stdin)
if err != nil {
fmt.Println(err.Error())
}
return string(bytes)
}()
// fmt.Println(webhook_url)
// fmt.Println(Format)
_, err := http.PostForm(webhook_url, url.Values{"format": {format}, "source": {source}})
if err != nil {
//fmt.Println(err.Error())
os.Exit(1)
}
// fmt.Println(resp.Status)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment