MCPcopy Index your code
hub / github.com/NdoleStudio/httpsms / do

Method do

api/pkg/discord/client.go:82–105  ·  view source on GitHub ↗

do carries out an HTTP request and returns a Response

(req *http.Request)

Source from the content-addressed store, hash-verified

80
81// do carries out an HTTP request and returns a Response
82func (client *Client) do(req *http.Request) (*Response, error) {
83 if req == nil {
84 return nil, fmt.Errorf("%T cannot be nil", req)
85 }
86
87 httpResponse, err := client.httpClient.Do(req)
88 if err != nil {
89 return nil, err
90 }
91
92 defer func() { _ = httpResponse.Body.Close() }()
93
94 resp, err := client.newResponse(httpResponse)
95 if err != nil {
96 return resp, err
97 }
98
99 _, err = io.Copy(io.Discard, httpResponse.Body)
100 if err != nil {
101 return resp, err
102 }
103
104 return resp, nil
105}
106
107// newResponse converts an *http.Response to *Response
108func (client *Client) newResponse(httpResponse *http.Response) (*Response, error) {

Callers 4

CreateCommandMethod · 0.80
CreateMessageMethod · 0.80
GetMethod · 0.80
GetMethod · 0.80

Calls 1

newResponseMethod · 0.95

Tested by

no test coverage detected