forked from assimon/captcha-bot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
41 lines (36 loc) · 795 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
package main
import (
"fmt"
"github.com/assimon/captcha-bot/bootstrap"
"io"
"log"
"net/http"
"strconv"
"time"
)
var counter = 0
func main() {
go func() {
http.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
counter++
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("counter", strconv.Itoa(counter))
fmt.Fprintf(w, "OK")
})
_ = http.ListenAndServe(":80", nil)
}()
go func() {
t := time.Tick(time.Second * 10)
for {
if resp, err := http.Get("https://captcha-bot-w3ht.onrender.com/healthz"); err != nil {
log.Default().Printf("error: " + err.Error())
} else {
if b, err := io.ReadAll(resp.Body); err == nil {
log.Default().Printf("health: " + string(b))
}
}
<-t
}
}()
bootstrap.Start()
}