press.go 806 B

1234567891011121314151617181920212223242526272829303132333435
  1. package main
  2. import (
  3. "crypto/tls"
  4. "fmt"
  5. "github.com/xxjwxc/gowp/workpool"
  6. "io/ioutil"
  7. "net/http"
  8. )
  9. func main() {
  10. wp := workpool.New(2)
  11. client := &http.Client{}
  12. url := "https://192.168.31.220:9090/api/v2/check_pppoe_business?pppoe=025051670554"
  13. req, _ := http.NewRequest("GET", url, nil)
  14. req.Header.Set("Authorization", "Basic cWlhbnhpbkJhc2ljQXV0aDpxaWFueGluQmFzaWNBdXRoI0AhWlhDCg==")
  15. tr := &http.Transport{
  16. TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
  17. }
  18. for i := 0; i < 10; i++ {
  19. wp.Do(func() error {
  20. client := &http.Client{Transport: tr}
  21. resp, err := client.Get("https://localhost:8081")
  22. if err != nil {
  23. fmt.Println("error:", err)
  24. }
  25. defer resp.Body.Close()
  26. body, err := ioutil.ReadAll(resp.Body)
  27. fmt.Println(string(body))
  28. })
  29. }
  30. wp.Wait()
  31. }