Skip to content

Commit

Permalink
initial commit for issue 69
Browse files Browse the repository at this point in the history
  • Loading branch information
RutvikS-crest authored and lhercot committed Apr 21, 2022
1 parent 95e99fa commit bec6691
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,42 @@ func GetClient(clientURL, username, password string, expiry int64, options ...Op
return clientImpl
}

func (c *Client) MakeRestNDRequest(method, path string, body *container.Container, authenticated bool) (*http.Request, error) {
url, err := url.Parse(path)
if err != nil {
return nil, err
}
reqURL := c.baseURL.ResolveReference(url)
log.Println("req", reqURL)
log.Println("req", reqURL.String())

var req *http.Request
if body == nil {
req, err = http.NewRequest(method, reqURL.String(), nil)
} else {
req, err = http.NewRequest(method, reqURL.String(), bytes.NewBuffer(body.Bytes()))
}
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
log.Printf("authenticated: %v\n", authenticated)
if authenticated {
log.Println("HTTP request ", method, path, req)
}
if authenticated {
req, err = c.injectAuthenticationHeader(req, path)
if err != nil {
return req, err
}
}
if authenticated {
log.Println("HTTP request after injection ", method, path, req)
}
log.Println("HTTP request after injection ", method, path, req)
return req, nil
}

func (c *Client) MakeRequest(method, path string, body *container.Container, authenticated bool) (*http.Request, error) {

if c.platform == "nd" && authenticated && !models.IsService(path) && !models.IsTemplate(path) {
Expand Down

0 comments on commit bec6691

Please sign in to comment.