Last active
March 1, 2016 10:21
-
-
Save stevenjack/083a631ebdb5a9064d17 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ( | |
"fmt" | |
"net/http" | |
"sync" | |
"time" | |
) | |
func main() { | |
domains := []string{"http://bbc.co.uk", "http://composition.newsbeat.news.cloud.bbc.co.uk"} | |
endpoints := []string{"newsbeat", "newsbeat/popular", "newsbeat/topics", "newsbeat/topics/entertainment", "newsbeat/topics/surgery", "newsbeat/article/32792353/im-engaged-but-will-i-ever-be-able-to-marry-my-boyfriend"} | |
var wg sync.WaitGroup | |
for _, domain := range domains { | |
for _, endpoint := range endpoints { | |
wg.Add(1) | |
go check(endpoint, domain, &wg) | |
} | |
} | |
wg.Wait() | |
} | |
func check(endpoint string, domain string, wg *sync.WaitGroup) { | |
defer wg.Done() | |
timeout := time.Duration(2 * time.Second) | |
client := http.Client{Timeout: timeout} | |
resp, _ := client.Get(fmt.Sprintf("%s/%s", domain, endpoint)) | |
fmt.Printf("%s/%s [%s]\n", domain, endpoint, resp.Status) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment