Created
July 28, 2020 14:11
-
-
Save dav1dddd/b5134d04d3386f91c8d1842e75fdd76f 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 ( | |
"bytes" | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
) | |
var ( | |
whurl = flag.String("whurl", "", "webhook url") | |
content = flag.String("content", "", "content") | |
) | |
func main() { | |
flag.Parse() | |
client := &http.Client{} | |
jsonstr := []byte(fmt.Sprintf(`{"content": "%v"}`, *content)) | |
request, err := http.NewRequest("POST", *whurl, bytes.NewBuffer(jsonstr)) | |
if err != nil { | |
panic(err) | |
} | |
request.Header.Add("Content-Type", "application/json") | |
response, err := client.Do(request) | |
if err != nil { | |
panic(err) | |
} | |
defer response.Body.Close() | |
// Read body | |
body, _ := ioutil.ReadAll(response.Body) | |
fmt.Println(string(body)) | |
fmt.Println(response.Status) | |
fmt.Println(response.Header) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment