MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / Call

Function Call

internal/request/request.go:57–74  ·  view source on GitHub ↗

Call makes an HTTP request using the provided request object and decodes the response into the specified structure. It automatically sets the request Content-Type to application/json and decodes the JSON response body into the provided response interface. Parameters: - req *http.Request: The prepar

(req *http.Request, response interface{})

Source from the content-addressed store, hash-verified

55// - *http.Response: The raw HTTP response object.
56// - error: An error if the HTTP request or JSON decoding fails.
57func Call(req *http.Request, response interface{}) (*http.Response, error) {
58 // Set request content type to JSON
59 req.Header.Set("Content-Type", "application/json")
60 client := &http.Client{}
61
62 // Send the HTTP request and capture the response
63 resp, err := client.Do(req)
64 if err != nil {
65 return resp, err
66 }
67
68 // Decode the JSON response into the provided response structure
69 err = json.NewDecoder(resp.Body).Decode(&response)
70 if err != nil {
71 return resp, err
72 }
73 return resp, err
74}
75
76// BasicAuth generates a basic HTTP authentication string by encoding the provided username and password.
77// The string is base64-encoded in the format "username:password".

Callers 5

applyExternalAccountFunction · 0.92
SlackNotificationFunction · 0.92
TestCall_SuccessFunction · 0.92
TestCall_Fail_DoRequestFunction · 0.92

Calls 1

SetMethod · 0.65

Tested by 3

TestCall_SuccessFunction · 0.74
TestCall_Fail_DoRequestFunction · 0.74