-
Notifications
You must be signed in to change notification settings - Fork 10
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
Support http proxies #15
Comments
this should probably live in kiota http if any code change is required, related microsoft/kiota#371 |
@baywet We might need to introduce a method on the One approach can be adapter, err := NewNetHttpRequestAdapter(authProvider)
adapter.UsingProxy("")
// or
adapter.WithProxie("") |
is this something that is set on the net/http client or on the request? |
This should be in the client itself //creating the proxyURL
proxyStr := "http://localhost:7000"
proxyURL, err := url.Parse(proxyStr)
if err != nil {
log.Println(err)
}
//creating the URL to be loaded through the proxy
urlStr := "http://httpbin.org/get"
url, err := url.Parse(urlStr)
if err != nil {
log.Println(err)
}
//adding the proxy settings to the Transport object
transport := &http.Transport{
Proxy: http.ProxyURL(proxyURL),
}
//adding the Transport object to the http Client
client := &http.Client{
Transport: transport,
} |
it's a lot of boiler plate code, and we're already using the transport for our middleware. Could we just improve the http client factory to take into account the proxy settings? like |
Added 2 factories to allow for proxy communication with and without authentication // GetDefaultClientWithProxySettings creates a new default net/http client with a proxy url and default middleware
func GetDefaultClientWithProxySettings(proxyUrlStr string) *nethttp.Client {
client := getDefaultClientWithoutMiddleware()
client.Transport = getTransportWithProxy(proxyUrlStr, nil)
return client
}
// GetDefaultClientWithAuthenticatedProxySettings creates a new default net/http client with a proxy url and default middleware
func GetDefaultClientWithAuthenticatedProxySettings(proxyUrlStr string, username string, password string) *nethttp.Client {
client := getDefaultClientWithoutMiddleware()
user := url.UserPassword(username, password)
client.Transport = getTransportWithProxy(proxyUrlStr, user)
return client
}
func getTransportWithProxy(proxyUrlStr string, user *url.Userinfo) nethttp.RoundTripper {
proxyURL, err := url.Parse(proxyUrlStr)
if err != nil {
log.Println(err)
}
if user != nil {
proxyURL.User = user
}
transport := &nethttp.Transport{
Proxy: nethttp.ProxyURL(proxyURL),
}
middlewares := GetDefaultMiddlewares()
return NewCustomTransportWithParentTransport(transport, middlewares...)
} |
Customers must be able to configure an HTTP proxy for the request adapter so the applications they build can run in networks that require accessing microsoft graph through a proxy.
Docs should also be updated once this is implemented
Tasks
The text was updated successfully, but these errors were encountered: