123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package edge_service
- import (
- "fmt"
- "io/ioutil"
- "iot_manager_service/config"
- "net/http"
- "net/url"
- )
- // Rewind 回放记录
- type ForRewindService struct {
- }
- // getRewindApi 公用请求接口
- func (f *ForRewindService) getRewindApi(url string) (string, error) {
- fmt.Printf("url = %v", url)
- method := "GET"
- client := &http.Client{}
- req, err := http.NewRequest(method, url, nil)
- if err != nil {
- fmt.Println(err)
- return "", nil
- }
- res, err := client.Do(req)
- if err != nil {
- fmt.Println(err)
- return "", nil
- }
- defer res.Body.Close()
- body, err := ioutil.ReadAll(res.Body)
- if err != nil {
- fmt.Println(err)
- return "", nil
- }
- fmt.Println(string(body))
- return string(body), err
- }
- func (f *ForRewindService) GetRewindText(streamId string, date string) (string, error) {
- //fmt.Printf("streamId = %v", streamId)
- cfg := config.Instance()
- api := cfg.Foreign.SecurityRewindUrl + "/list/%v/%v"
- url2 := fmt.Sprintf(api, (streamId), url.QueryEscape(date))
- //fmt.Printf("url2 = %v", url2)
- //return "", nil
- return f.getRewindApi(url2)
- }
|