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

Improve base URL configuration #5

Open
jmcampanini opened this issue Oct 15, 2018 · 0 comments
Open

Improve base URL configuration #5

jmcampanini opened this issue Oct 15, 2018 · 0 comments

Comments

@jmcampanini
Copy link
Member

// originally suggested by @bluekeyes

Currently, users have to specify the base URL three times in configuration:

  1. The web URL, used for the OAuth login flow
  2. The v3 API URL
  3. The v4 API URL

It seems like we should be able to compute all of these given a single base URL, as long as we assume that github.com works in a known consistent way (most other client libraries seem to assume this.) Something like:

  • If if the base URL host is github.com, use api.github.com and api.github.com/graphql
  • Otherwise, assume an enterprise installation and use baseURL/api/v3 and baseURL/api/v4/graphql

The place where this would break is if someone is running a named proxy for github.com (i.e. not using the native proxy support in http.Client) or if someone put a proxy in front of their enterprise install to mess with the URLs. I don't think it's worth support either of those cases.

Maybe something like this:

type URLs struct {
  Web   *url.URL
  APIv3 *url.URL
  APIv4 *url.URL
}

func NewURLs(baseURL string) (*URLs, error) {
  // parse baseURL, set others based on if it contains github.com or not
}

Then ClientCreator could take one of these objects and BaseHandler could expose one for use in other places if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant