Skip to content
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: init api server configs with path of host  #511

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions api/configuration_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ func NewAPIConfig(params ConfigParams) *Configuration {
apiConfig.Scheme = params.Host.Scheme
apiConfig.UserAgent = params.UserAgent
apiConfig.HTTPClient = &http.Client{Transport: clientTransport}

if params.Host.Path != "" {
// initialize api server configurations with path of host url
apiConfig.Servers = ServerConfigurations{{URL: params.Host.Path}}
for key := range apiConfig.OperationServers {
apiConfig.OperationServers[key] = ServerConfigurations{{URL: params.Host.Path}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this looks relatively straightforward and like it will address the issue.

My one reservation is that it completely overrides the existing apiConfig.OperationServers[key] value. We don't lose any valuable information today (just a non-useful description), but I'm concerned this could introduce subtle issues in the future if more valuable information is already populated in the ServerConfigurations.

Would it be possible to set the URL value without overwriting everything else?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gwossum Just to handle the path part, you can take a look at #530 which do a light prepend on constructing the final request.

}
}

if params.Token != nil && *params.Token != "" {
apiConfig.DefaultHeader["Authorization"] = fmt.Sprintf("Token %s", *params.Token)
} else if params.Cookie != nil && *params.Cookie != "" {
Expand Down