(room string, timerService string, disableSslVerification bool)
| 107 | return nil |
| 108 | } |
| 109 | func getGoalHttp(room string, timerService string, disableSslVerification bool) (string, error) { |
| 110 | url := timerService + room + "/goal" |
| 111 | response, err := httpclient.GetNetHttpClient(disableSslVerification).Get(url) |
| 112 | if err != nil { |
| 113 | say.Debug(err.Error()) |
| 114 | return "", err |
| 115 | } |
| 116 | if response.StatusCode >= 300 { |
| 117 | return "", errors.New("got an error while requesting it: " + url + " " + response.Status) |
| 118 | } |
| 119 | if response.StatusCode == 204 { |
| 120 | return "", nil |
| 121 | } |
| 122 | body, err := io.ReadAll(response.Body) |
| 123 | if err != nil { |
| 124 | say.Debug(err.Error()) |
| 125 | return "", err |
| 126 | } |
| 127 | var goalResponse GoalResponse |
| 128 | if err := json.Unmarshal(body, &goalResponse); err != nil { |
| 129 | say.Debug(err.Error()) |
| 130 | return "", err |
| 131 | } |
| 132 | return goalResponse.Goal, nil |
| 133 | } |
| 134 | |
| 135 | var exit = func(code int) { |
| 136 | os.Exit(code) |
no test coverage detected