-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
42 lines (35 loc) · 819 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"fmt"
"net/http"
"github.com/apple-yagi/congo/handler"
"github.com/apple-yagi/congo/scrape"
)
func main() {
var resp1 http.Response
var resp2 http.Response
var resp3 http.Response
funcs := []handler.GenericFunction{
makeRequest("https://example.com", &resp1),
makeRequest("https://example2.com", &resp2),
makeRequest("https://example3.com/", &resp3),
}
errs := (handler.RunAsyncAllowErrors(funcs...))
for i := range errs {
if errs[i] != nil {
fmt.Println("An error occurred in resp", i, ": ", errs[i])
}
}
}
func makeRequest(url string, response *http.Response) handler.GenericFunction {
return func() error {
resp, err := http.Get(url)
if err != nil {
return err
}
response = resp
// Scraping response
scrape.ScrapeText(response)
return nil
}
}