MCPcopy Index your code
hub / github.com/dnote/dnote / getReq

Function getReq

pkg/cli/client/client.go:122–137  ·  view source on GitHub ↗
(ctx context.DnoteCtx, path, method, body string)

Source from the content-addressed store, hash-verified

120}
121
122func getReq(ctx context.DnoteCtx, path, method, body string) (*http.Request, error) {
123 endpoint := fmt.Sprintf("%s%s", ctx.APIEndpoint, path)
124 req, err := http.NewRequest(method, endpoint, strings.NewReader(body))
125 if err != nil {
126 return nil, errors.Wrap(err, "constructing http request")
127 }
128
129 req.Header.Set("CLI-Version", ctx.Version)
130
131 if ctx.SessionKey != "" {
132 credential := fmt.Sprintf("Bearer %s", ctx.SessionKey)
133 req.Header.Set("Authorization", credential)
134 }
135
136 return req, nil
137}
138
139// checkRespErr checks if the given http response indicates an error. It returns a boolean indicating
140// if the response is an error, and a decoded error message.

Callers 1

doReqFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected