-
Notifications
You must be signed in to change notification settings - Fork 60
Description
// originally suggested by @bluekeyes
Currently, users have to specify the base URL three times in configuration:
- The web URL, used for the OAuth login flow
- The v3 API URL
- 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
, useapi.github.com
andapi.github.com/graphql
- Otherwise, assume an enterprise installation and use
baseURL/api/v3
andbaseURL/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.