ipcast.go 503 B

1234567891011121314151617181920212223242526272829
  1. package ipcast
  2. import (
  3. "bytes"
  4. "io/ioutil"
  5. "net/http"
  6. )
  7. type IpcastService struct {
  8. }
  9. func (s *IpcastService) Common(url, method string, data []byte) (resp []byte, err error) {
  10. c := http.Client{}
  11. request, err := http.NewRequest(method, url, bytes.NewBuffer(data))
  12. if err != nil {
  13. return nil, err
  14. }
  15. do, err := c.Do(request)
  16. if err != nil {
  17. return nil, err
  18. }
  19. body := do.Body
  20. defer body.Close()
  21. all, err := ioutil.ReadAll(body)
  22. if err != nil {
  23. return nil, err
  24. }
  25. return all, nil
  26. }