Improvements on versioning.

pull/122/head
Halil İbrahim Kalkan 7 years ago
parent 0635e74ed6
commit 7cb0a887e5

@ -100,7 +100,7 @@ namespace Volo.Abp.AspNetCore.Mvc
private static string GetUniqueActionName(MethodInfo method)
{
var methodNameBuilder = new StringBuilder(method.Name.RemovePostFix("Async"));
var methodNameBuilder = new StringBuilder(method.Name);
var parameters = method.GetParameters();
if (parameters.Any())

@ -16,9 +16,9 @@ namespace Volo.Abp.Http.Client.DynamicProxying
_descriptionCache = descriptionCache;
}
public async Task<ActionApiDescriptionModel> FindActionAsync(RemoteServiceConfiguration proxyConfig, Type serviceType, MethodInfo method)
public async Task<ActionApiDescriptionModel> FindActionAsync(string baseUrl, Type serviceType, MethodInfo method)
{
var apiDescription = await _descriptionCache.GetAsync(proxyConfig.BaseUrl);
var apiDescription = await _descriptionCache.GetAsync(baseUrl);
//TODO: Cache finding?

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

@ -7,6 +7,6 @@ namespace Volo.Abp.Http.Client.DynamicProxying
{
public interface IApiDescriptionFinder
{
Task<ActionApiDescriptionModel> FindActionAsync(RemoteServiceConfiguration proxyConfig, Type serviceType, MethodInfo invocationMethod);
Task<ActionApiDescriptionModel> FindActionAsync(string baseUrl, Type serviceType, MethodInfo invocationMethod);
}
}

@ -4,6 +4,8 @@
{
public string BaseUrl { get; set; }
public string Version { get; set; }
public RemoteServiceConfiguration()
{

@ -52,5 +52,10 @@ namespace Volo.Abp.Http.Modeling
{
return HttpMethodHelper.ConvertToHttpMethod(HttpMethod);
}
public override string ToString()
{
return $"[ActionApiDescriptionModel {Name}]";
}
}
}

@ -73,5 +73,10 @@ namespace Volo.Abp.Http.Modeling
{
return Interfaces.Any(i => i.TypeAsString == interfaceType.GetFullNameWithAssemblyName());
}
public override string ToString()
{
return $"[ControllerApiDescriptionModel {ControllerName}]";
}
}
}
Loading…
Cancel
Save