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

Allowing custom API endpoint in NewClient config #198

Closed
alibasim86 opened this issue Feb 17, 2020 · 6 comments
Closed

Allowing custom API endpoint in NewClient config #198

alibasim86 opened this issue Feb 17, 2020 · 6 comments

Comments

@alibasim86
Copy link

Hi,

Can we allow API Endpoint customization during client creation to allow the run from an air gapped environment where calls are made via an API gateway.

func NewClient(authToken string) *Client {

Thanks
Ali

@stmcallister
Copy link
Contributor

Hi @alibasim86! That's an interesting thought. While we think about ways we could address this, does your API gateway support a proxy mode? We do pick up environment proxy settings if you have HTTP_PROXY or HTTPS_PROXY.

@alibasim86
Copy link
Author

Hi, even if the API gateway supports its the system internally that is using the go-pagerduty will be pointing to a custom URL (that's the API gateway) to talk to PagerDuty public API endpoints for both API and events.
ie:
api.pagerduty.com might be vip.mydomain.com/api
events.pagerduty.com might be vip.mydomain.com/events

Thanks
Ali

@stmcallister
Copy link
Contributor

Would a function like this do the trick?

func NewClientWithAPIEndpoint(authToken, apiEndpoint string) *Client {
	return &Client{
		authToken:   authToken,
		apiEndpoint: apiEndpoint,
		authType:    apiToken,
		HTTPClient:  defaultHTTPClient,
	}
}

@alibasim86
Copy link
Author

yep, That would do it. Thank you

@stmcallister
Copy link
Contributor

So, we went with a little bit different of an approach. The way you'll set a custom APIEndpoint will look something like this:

client := NewClient("SOME_TOKEN", WithAPIEndpoint("https://mypdapi.com"))

@stmcallister
Copy link
Contributor

Please comment, or post another issue, if you have further trouble with this.

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

2 participants