|
|
@ -94,9 +94,11 @@ namespace Volo.Abp.Http.Client.DynamicProxying |
|
|
{ |
|
|
{ |
|
|
using (var client = _httpClientFactory.Create()) |
|
|
using (var client = _httpClientFactory.Create()) |
|
|
{ |
|
|
{ |
|
|
var proxyConfig = GetProxyConfig(); |
|
|
var baseUrl = GetBaseUrl(); |
|
|
var action = await _apiDescriptionFinder.FindActionAsync(proxyConfig, typeof(TService), invocation.Method); |
|
|
var version = GetVersion(); //TODO: Add version to the request (querystring, media type, path value or custom header!)
|
|
|
var url = proxyConfig.BaseUrl + UrlBuilder.GenerateUrlWithParameters(action, invocation.ArgumentsDictionary); |
|
|
|
|
|
|
|
|
var action = await _apiDescriptionFinder.FindActionAsync(baseUrl, typeof(TService), invocation.Method); |
|
|
|
|
|
var url = baseUrl + UrlBuilder.GenerateUrlWithParameters(action, invocation.ArgumentsDictionary); |
|
|
|
|
|
|
|
|
var requestMessage = new HttpRequestMessage(action.GetHttpMethod(), url) |
|
|
var requestMessage = new HttpRequestMessage(action.GetHttpMethod(), url) |
|
|
{ |
|
|
{ |
|
|
@ -128,16 +130,24 @@ namespace Volo.Abp.Http.Client.DynamicProxying |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private RemoteServiceConfiguration GetProxyConfig() |
|
|
private string GetBaseUrl() |
|
|
{ |
|
|
{ |
|
|
var clientConfig = _clientOptions.HttpClientProxies.GetOrDefault(typeof(TService)) |
|
|
var clientConfig = _clientOptions.HttpClientProxies.GetOrDefault(typeof(TService)) |
|
|
?? throw new AbpException($"Could not get DynamicHttpClientProxyConfig for {typeof(TService).FullName}."); |
|
|
?? throw new AbpException($"Could not get DynamicHttpClientProxyConfig for {typeof(TService).FullName}."); |
|
|
|
|
|
|
|
|
return _remoteServiceOptions.RemoteServices.GetOrDefault(clientConfig.RemoteServiceName) |
|
|
return _remoteServiceOptions.RemoteServices.GetOrDefault(clientConfig.RemoteServiceName)?.BaseUrl |
|
|
?? _remoteServiceOptions.RemoteServices.Default |
|
|
?? _remoteServiceOptions.RemoteServices.Default?.BaseUrl |
|
|
?? throw new AbpException($"Could not get DynamicHttpClientProxyConfig for {typeof(TService).FullName}."); |
|
|
?? throw new AbpException($"Could not find Base URL for {typeof(TService).FullName}."); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private string GetVersion() |
|
|
|
|
|
{ |
|
|
|
|
|
var clientConfig = _clientOptions.HttpClientProxies.GetOrDefault(typeof(TService)) |
|
|
|
|
|
?? throw new AbpException($"Could not get DynamicHttpClientProxyConfig for {typeof(TService).FullName}."); |
|
|
|
|
|
|
|
|
|
|
|
return _remoteServiceOptions.RemoteServices.GetOrDefault(clientConfig.RemoteServiceName)?.Version |
|
|
|
|
|
?? _remoteServiceOptions.RemoteServices.Default?.Version; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private async Task ThrowExceptionForResponseAsync(HttpResponseMessage response) |
|
|
private async Task ThrowExceptionForResponseAsync(HttpResponseMessage response) |
|
|
{ |
|
|
{ |
|
|
|