Created
November 9, 2013 09:32
-
-
Save bash0C7/7383655 to your computer and use it in GitHub Desktop.
Idobata General Webhook Client (golang)
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 "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