MCPcopy Create free account
hub / github.com/remotemobprogramming/mob / getGoalHttp

Function getGoalHttp

goal/goal.go:109–133  ·  view source on GitHub ↗
(room string, timerService string, disableSslVerification bool)

Source from the content-addressed store, hash-verified

107 return nil
108}
109func 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
135var exit = func(code int) {
136 os.Exit(code)

Callers 1

showGoalFunction · 0.85

Calls 2

GetNetHttpClientFunction · 0.92
DebugFunction · 0.92

Tested by

no test coverage detected