MCPcopy Create free account
hub / github.com/aiprodcoder/MIXAPI / DoApiRequest

Function DoApiRequest

relay/channel/api_request.go:37–58  ·  view source on GitHub ↗
(a Adaptor, c *gin.Context, info *common.RelayInfo, requestBody io.Reader)

Source from the content-addressed store, hash-verified

35}
36
37func DoApiRequest(a Adaptor, c *gin.Context, info *common.RelayInfo, requestBody io.Reader) (*http.Response, error) {
38 fullRequestURL, err := a.GetRequestURL(info)
39 if err != nil {
40 return nil, fmt.Errorf("get request url failed: %w", err)
41 }
42 if common2.DebugEnabled {
43 println("fullRequestURL:", fullRequestURL)
44 }
45 req, err := http.NewRequest(c.Request.Method, fullRequestURL, requestBody)
46 if err != nil {
47 return nil, fmt.Errorf("new request failed: %w", err)
48 }
49 err = a.SetupRequestHeader(c, &req.Header, info)
50 if err != nil {
51 return nil, fmt.Errorf("setup request header failed: %w", err)
52 }
53 resp, err := doRequest(c, req, info)
54 if err != nil {
55 return nil, fmt.Errorf("do request failed: %w", err)
56 }
57 return resp, nil
58}
59
60func DoFormRequest(a Adaptor, c *gin.Context, info *common.RelayInfo, requestBody io.Reader) (*http.Response, error) {
61 fullRequestURL, err := a.GetRequestURL(info)

Callers 15

DoRequestMethod · 0.92
DoRequestMethod · 0.92
DoRequestMethod · 0.92
DoRequestMethod · 0.92
DoRequestMethod · 0.92
DoRequestMethod · 0.92
DoRequestMethod · 0.92
DoRequestMethod · 0.92
DoRequestMethod · 0.92
DoRequestMethod · 0.92
DoRequestMethod · 0.92
DoRequestMethod · 0.92

Calls 3

doRequestFunction · 0.70
GetRequestURLMethod · 0.65
SetupRequestHeaderMethod · 0.65

Tested by

no test coverage detected