diff --git a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs index 8368b2e9d0..594850d10c 100644 --- a/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs +++ b/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs @@ -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()) diff --git a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs index 206b55c2a4..34df0deecb 100644 --- a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs +++ b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs @@ -16,9 +16,9 @@ namespace Volo.Abp.Http.Client.DynamicProxying _descriptionCache = descriptionCache; } - public async Task FindActionAsync(RemoteServiceConfiguration proxyConfig, Type serviceType, MethodInfo method) + public async Task FindActionAsync(string baseUrl, Type serviceType, MethodInfo method) { - var apiDescription = await _descriptionCache.GetAsync(proxyConfig.BaseUrl); + var apiDescription = await _descriptionCache.GetAsync(baseUrl); //TODO: Cache finding? diff --git a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs index fbd533dbba..db9b4e779a 100644 --- a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs +++ b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs @@ -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) { diff --git a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/IApiDescriptionFinder.cs b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/IApiDescriptionFinder.cs index af34a505c9..ede988b4b9 100644 --- a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/IApiDescriptionFinder.cs +++ b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/IApiDescriptionFinder.cs @@ -7,6 +7,6 @@ namespace Volo.Abp.Http.Client.DynamicProxying { public interface IApiDescriptionFinder { - Task FindActionAsync(RemoteServiceConfiguration proxyConfig, Type serviceType, MethodInfo invocationMethod); + Task FindActionAsync(string baseUrl, Type serviceType, MethodInfo invocationMethod); } } \ No newline at end of file diff --git a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/RemoteServiceConfiguration.cs b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/RemoteServiceConfiguration.cs index 666b9b4d5d..bf2f30133b 100644 --- a/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/RemoteServiceConfiguration.cs +++ b/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/RemoteServiceConfiguration.cs @@ -4,6 +4,8 @@ { public string BaseUrl { get; set; } + public string Version { get; set; } + public RemoteServiceConfiguration() { diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ActionApiDescriptionModel.cs b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ActionApiDescriptionModel.cs index 9b93ea792c..ffed6f2184 100644 --- a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ActionApiDescriptionModel.cs +++ b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ActionApiDescriptionModel.cs @@ -52,5 +52,10 @@ namespace Volo.Abp.Http.Modeling { return HttpMethodHelper.ConvertToHttpMethod(HttpMethod); } + + public override string ToString() + { + return $"[ActionApiDescriptionModel {Name}]"; + } } } \ No newline at end of file diff --git a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs index 9d7216d357..2bd9a301ab 100644 --- a/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs +++ b/src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs @@ -73,5 +73,10 @@ namespace Volo.Abp.Http.Modeling { return Interfaces.Any(i => i.TypeAsString == interfaceType.GetFullNameWithAssemblyName()); } + + public override string ToString() + { + return $"[ControllerApiDescriptionModel {ControllerName}]"; + } } } \ No newline at end of file