mirror of
https://github.com/passbolt/go-passbolt.git
synced 2025-05-10 01:48:22 +00:00
feat: deprecating api-version query param in api calls
This commit is contained in:
parent
7a23a1aeea
commit
9eb37766a8
2 changed files with 8 additions and 6 deletions
|
@ -33,9 +33,14 @@ func (c *Client) DoCustomRequest(ctx context.Context, method, path, version stri
|
||||||
|
|
||||||
// DoCustomRequestAndReturnRawResponse Executes a Custom Request and returns a APIResponse and the Raw HTTP Response
|
// DoCustomRequestAndReturnRawResponse Executes a Custom Request and returns a APIResponse and the Raw HTTP Response
|
||||||
func (c *Client) DoCustomRequestAndReturnRawResponse(ctx context.Context, method, path, version string, body interface{}, opts interface{}) (*http.Response, *APIResponse, error) {
|
func (c *Client) DoCustomRequestAndReturnRawResponse(ctx context.Context, method, path, version string, body interface{}, opts interface{}) (*http.Response, *APIResponse, error) {
|
||||||
|
// version is no longer used and is ignored.
|
||||||
|
return c.DoCustomRequestAndReturnRawResponseV5(ctx, method, path, body, opts)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) DoCustomRequestAndReturnRawResponseV5(ctx context.Context, method, path string, body interface{}, opts interface{}) (*http.Response, *APIResponse, error) {
|
||||||
firstTime := true
|
firstTime := true
|
||||||
start:
|
start:
|
||||||
u, err := generateURL(*c.baseURL, path, version, opts)
|
u, err := generateURL(*c.baseURL, path, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, fmt.Errorf("Generating Path: %w", err)
|
return nil, nil, fmt.Errorf("Generating Path: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,17 +169,14 @@ func (c *Client) log(msg string, args ...interface{}) {
|
||||||
fmt.Printf("[go-passbolt] "+msg+"\n", args...)
|
fmt.Printf("[go-passbolt] "+msg+"\n", args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateURL(base url.URL, p, version string, opt interface{}) (string, error) {
|
func generateURL(base url.URL, p string, opt interface{}) (string, error) {
|
||||||
base.Path = path.Join(base.Path, p)
|
base.Path = path.Join(base.Path, p)
|
||||||
|
|
||||||
vs, err := query.Values(opt)
|
vs, err := query.Values(opt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("Getting URL Query Values: %w", err)
|
return "", fmt.Errorf("Getting URL Query Values: %w", err)
|
||||||
}
|
}
|
||||||
if version != "" {
|
|
||||||
vs.Add("api-version", version)
|
|
||||||
}
|
|
||||||
base.RawQuery = vs.Encode()
|
base.RawQuery = vs.Encode()
|
||||||
|
|
||||||
return base.String(), nil
|
return base.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue