Browse Source

Remove module name while creating http client proxies.

pull/113/head
Halil İbrahim Kalkan 9 years ago
parent
commit
4f359fb677
  1. 2
      src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceConvention.cs
  2. 2
      src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AppServiceControllerOptions.cs
  3. 4
      src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs
  4. 12
      src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs
  5. 7
      src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs
  6. 5
      src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpClientProxyConfig.cs
  7. 5
      src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs
  8. 2
      src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerInterfaceApiDescriptionModel.cs
  9. 2
      src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs

2
src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAppServiceConvention.cs

@ -244,7 +244,7 @@ namespace Volo.Abp.AspNetCore.Mvc
protected virtual string GetModuleNameOrDefault(Type controllerType)
{
return GetControllerSettingOrNull(controllerType)?.ModuleName ??
ModuleApiDescriptionModel.DefaultServiceModuleName;
ModuleApiDescriptionModel.DefaultModuleName;
}
[CanBeNull]

2
src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AppServiceControllerOptions.cs

@ -29,7 +29,7 @@ namespace Volo.Abp.AspNetCore.Mvc
};
}
public AbpControllerAssemblySettingBuilder CreateFor(Assembly assembly, string moduleName = ModuleApiDescriptionModel.DefaultServiceModuleName)
public AbpControllerAssemblySettingBuilder CreateFor(Assembly assembly, string moduleName = ModuleApiDescriptionModel.DefaultModuleName)
{
var setting = new AbpControllerAssemblySetting(assembly, moduleName);
ControllerAssemblySettings.Add(setting);

4
src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs

@ -158,7 +158,7 @@ namespace Volo.Abp.AspNetCore.Mvc
{
if (controllerType == null)
{
return ModuleApiDescriptionModel.DefaultServiceModuleName;
return ModuleApiDescriptionModel.DefaultModuleName;
}
foreach (var controllerSetting in _options.AppServiceControllers.ControllerAssemblySettings)
@ -175,7 +175,7 @@ namespace Volo.Abp.AspNetCore.Mvc
return areaAttr.RouteValue;
}
return ModuleApiDescriptionModel.DefaultServiceModuleName;
return ModuleApiDescriptionModel.DefaultModuleName;
}
}
}

12
src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs

@ -18,7 +18,7 @@ namespace Microsoft.Extensions.DependencyInjection
this IServiceCollection services,
Assembly assembly,
string baseUrl,
string moduleName = ModuleApiDescriptionModel.DefaultServiceModuleName)
string moduleName = ModuleApiDescriptionModel.DefaultModuleName)
{
//TODO: Add option to change type filter
@ -28,22 +28,22 @@ namespace Microsoft.Extensions.DependencyInjection
foreach (var serviceType in serviceTypes)
{
services.AddHttpClientProxy(serviceType, baseUrl, moduleName);
services.AddHttpClientProxy(serviceType, baseUrl);
}
return services;
}
public static IServiceCollection AddHttpClientProxy<T>(this IServiceCollection services, string baseUrl, string moduleName = ModuleApiDescriptionModel.DefaultServiceModuleName)
public static IServiceCollection AddHttpClientProxy<T>(this IServiceCollection services, string baseUrl)
{
return services.AddHttpClientProxy(typeof(T), baseUrl, moduleName);
return services.AddHttpClientProxy(typeof(T), baseUrl);
}
public static IServiceCollection AddHttpClientProxy(this IServiceCollection services, Type type, string baseUrl, string moduleName = ModuleApiDescriptionModel.DefaultServiceModuleName)
public static IServiceCollection AddHttpClientProxy(this IServiceCollection services, Type type, string baseUrl)
{
services.Configure<AbpHttpClientOptions>(options =>
{
options.HttpClientProxies[type] = new DynamicHttpClientProxyConfig(moduleName, baseUrl, type);
options.HttpClientProxies[type] = new DynamicHttpClientProxyConfig(baseUrl, type);
});
var interceptorType = typeof(DynamicHttpProxyInterceptor<>).MakeGenericType(type);

7
src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs

@ -25,14 +25,9 @@ namespace Volo.Abp.Http.Client.DynamicProxying
foreach (var module in apiDescription.Modules.Values)
{
if (module.Name != proxyConfig.ModuleName)
{
continue;
}
foreach (var controller in module.Controllers.Values)
{
if (controller.Interfaces.All(i => i.TypeAsString != proxyConfig.Type.FullName))
if (!controller.Implements(proxyConfig.Type))
{
continue;
}

5
src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpClientProxyConfig.cs

@ -6,14 +6,11 @@ namespace Volo.Abp.Http.Client.DynamicProxying
{
public string BaseUrl { get; }
public string ModuleName { get; }
public Type Type { get; }
public DynamicHttpClientProxyConfig(string moduleName, string baseUrl, Type type)
public DynamicHttpClientProxyConfig(string baseUrl, Type type)
{
BaseUrl = baseUrl;
ModuleName = moduleName;
Type = type;
}
}

5
src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerApiDescriptionModel.cs

@ -66,5 +66,10 @@ namespace Volo.Abp.Http.Modeling
return subModel;
}
public bool Implements(Type interfaceType)
{
return Interfaces.Any(i => i.TypeAsString == interfaceType.AssemblyQualifiedName);
}
}
}

2
src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ControllerInterfaceApiDescriptionModel.cs

@ -16,7 +16,7 @@ namespace Volo.Abp.Http.Modeling
{
return new ControllerInterfaceApiDescriptionModel
{
TypeAsString = type.FullName
TypeAsString = type.AssemblyQualifiedName
};
}
}

2
src/Volo.Abp.Http/Volo/Abp/Http/Modeling/ModuleApiDescriptionModel.cs

@ -10,7 +10,7 @@ namespace Volo.Abp.Http.Modeling
/// <summary>
/// "app".
/// </summary>
public const string DefaultServiceModuleName = "app";
public const string DefaultModuleName = "app";
public string Name { get; set; }

Loading…
Cancel
Save