You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

base.go 1.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package httpclient
  2. import (
  3. "crypto/tls"
  4. "github.com/go-resty/resty/v2"
  5. "time"
  6. )
  7. const (
  8. ContentType = "Content-Type"
  9. ApplicationJson = "application/json"
  10. MutipartFormData = "multipart/form-data; boundary=<calculated when request is sent>"
  11. ApplicationFromUrlencoded = "application/x-www-from-urlencoded"
  12. )
  13. var httpClient *resty.Client = nil
  14. var httpsClient *resty.Client = nil
  15. func NewHttpClient() *resty.Client {
  16. if httpClient != nil {
  17. return httpClient
  18. }
  19. httpClient = resty.New()
  20. httpClient.SetTimeout(5 * time.Second)
  21. httpClient.SetRetryCount(3)
  22. //debug := config.GetConfig("httpclient.debug")
  23. debug := "true"
  24. if len(debug) > 0 && debug == "ON" {
  25. httpClient.SetDebug(true)
  26. }
  27. return httpClient
  28. }
  29. func NewHttpsClient() *resty.Client {
  30. if httpsClient != nil {
  31. return httpsClient
  32. }
  33. c := resty.New()
  34. c.SetTLSClientConfig(&tls.Config{InsecureSkipVerify: true})
  35. c.SetTimeout(5 * time.Second)
  36. c.SetRetryCount(3)
  37. //debug := config.GetConfig("httpclient.debug")
  38. debug := "true"
  39. if len(debug) > 0 && debug == "ON" {
  40. c.SetDebug(true)
  41. }
  42. httpsClient = c
  43. return c
  44. }

PCM is positioned as Software stack over Cloud, aiming to build the standards and ecology of heterogeneous cloud collaboration for JCC in a non intrusive and autonomous peer-to-peer manner.