MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / mustPostMessage

Function mustPostMessage

mcp/streamable_example_test.go:72–80  ·  view source on GitHub ↗

!-httpmiddleware

(msg, url string)

Source from the content-addressed store, hash-verified

70// !-httpmiddleware
71
72func 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
82func orFatal[T any](t T, err error) T {
83 if err != nil {

Calls 2

orFatalFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…