!-httpmiddleware
(msg, url string)
| 70 | // !-httpmiddleware |
| 71 | |
| 72 | func mustPostMessage(msg, url string) string { |
| 73 | req := orFatal(http.NewRequest("POST", url, strings.NewReader(msg))) |
| 74 | req.Header["Content-Type"] = []string{"application/json"} |
| 75 | req.Header["Accept"] = []string{"application/json", "text/event-stream"} |
| 76 | resp := orFatal(http.DefaultClient.Do(req)) |
| 77 | defer resp.Body.Close() |
| 78 | body := orFatal(io.ReadAll(resp.Body)) |
| 79 | return string(body) |
| 80 | } |
| 81 | |
| 82 | func orFatal[T any](t T, err error) T { |
| 83 | if err != nil { |
no test coverage detected
searching dependent graphs…