package main import ( "bytes" "encoding/json" "fmt" "io/ioutil" "log" "net/http" "os" ) func main() { if len(os.Args) < 2 { log.Fatalln("usage: ap-inspect BLOG-URL") } blogURL := os.Args[1] // Set up request req, err := http.NewRequest("GET", blogURL, nil) if err != nil { log.Fatalln(err) } req.Header.Set("Accept", "application/activity+json") // Send request client := &http.Client{} resp, err := client.Do(req) if err != nil { log.Fatalln(err) } if resp != nil && resp.Body != nil { defer resp.Body.Close() } body, err := ioutil.ReadAll(resp.Body) if err != nil { log.Fatalln(err) } fmt.Printf("Status : %s\n", resp.Status) // Pretty-print the response var fmttd bytes.Buffer err = json.Indent(&fmttd, body, "", " ") if err != nil { log.Fatalln(err) } fmt.Printf("Response:\n%s\n", fmttd.String()) }