-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cloudian-sdk): add cloudian user #61
Conversation
internal/sdk/cloudian/sdk.go
Outdated
url := client.baseURL + "/user" | ||
|
||
// We can create an internal type for this json data later, if needed | ||
jsonData, err := json.Marshal(toInternalUser(user)) | ||
if err != nil { | ||
return fmt.Errorf("error marshaling JSON: %w", err) | ||
} | ||
|
||
req, err := client.newRequest(ctx, url, http.MethodPut, jsonData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move url
to where it's used?
url := client.baseURL + "/user" | |
// We can create an internal type for this json data later, if needed | |
jsonData, err := json.Marshal(toInternalUser(user)) | |
if err != nil { | |
return fmt.Errorf("error marshaling JSON: %w", err) | |
} | |
req, err := client.newRequest(ctx, url, http.MethodPut, jsonData) | |
// We can create an internal type for this json data later, if needed | |
jsonData, err := json.Marshal(toInternalUser(user)) | |
if err != nil { | |
return fmt.Errorf("error marshaling JSON: %w", err) | |
} | |
url := client.baseURL + "/user" | |
req, err := client.newRequest(ctx, url, http.MethodPut, jsonData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda like having it as the first var in every exported function. This way we can see at a glance what endpoint we invoke. But I don't have an issue with moving it down..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
come to think of it - the whole var could be inlined. gofmt wants no spaces between that +
Co-authored-by: Amund Tenstad <[email protected]>
return fmt.Errorf("error marshaling JSON: %w", err) | ||
} | ||
|
||
req, err := client.newRequest(ctx, client.baseURL+"/user", http.MethodPut, jsonData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't the base URL handled inside the client newRequest
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would make sense, but perhaps in a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supporting leaving it be for now and fixing in new PR
No description provided.