MCPcopy Create free account
hub / github.com/cloudbase/garm / NewRequest

Method NewRequest

cmd/garm-cli/cmd/util.go:161–176  ·  view source on GitHub ↗

NewRequest creates a new HTTP request with auth and proper URL

(method, path string, body io.Reader)

Source from the content-addressed store, hash-verified

159
160// NewRequest creates a new HTTP request with auth and proper URL
161func (c *rawClient) NewRequest(method, path string, body io.Reader) (*http.Request, error) {
162 url, err := url.JoinPath(c.BaseURL, path)
163 if err != nil {
164 return nil, fmt.Errorf("failed to join URL: %w", err)
165 }
166
167 req, err := http.NewRequest(method, url, body) //nolint:gosec // G704 - URL is constructed from configured base URL
168 if err != nil {
169 return nil, err
170 }
171
172 // Add JWT token
173 req.Header.Set("Authorization", "Bearer "+c.Token)
174
175 return req, nil
176}

Callers 4

file_object.goFile · 0.80
controller.goFile · 0.80
createGiteaRepoHookMethod · 0.80
createGiteaOrgHookMethod · 0.80

Calls 1

SetMethod · 0.45

Tested by

no test coverage detected