Browse Source

Merge pull request #1 from abpframework/master

pull latest from source
pull/1351/head
Joe 7 years ago
committed by GitHub
parent
commit
a22d5831f2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      docs/en/AspNetCore/Tag-Helpers.md
  2. 3
      docs/en/AspNetCore/Tag-Helpers/Dynamic-Forms.md
  3. 0
      docs/en/AspNetCore/Tag-Helpers/Index.md
  4. 3
      docs/en/Aspect-Oriented-Programming.md
  5. 3
      docs/en/Caching.md
  6. 3
      docs/en/CorrelationId.md
  7. 3
      docs/en/Data-Filtering.md
  8. 3
      docs/en/Specifications.md
  9. 2
      docs/en/docs-nav.json
  10. 9
      framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/DynamicProxying/AspNetCoreTestDynamicProxyHttpClientFactory.cs
  11. 2
      framework/src/Volo.Abp.Http.Client.IdentityModel/Volo/Abp/Http/Client/IdentityModel/IdentityModelRemoteServiceHttpClientAuthenticator.cs
  12. 7
      framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs
  13. 3
      framework/src/Volo.Abp.Http.Client/Volo.Abp.Http.Client.csproj
  14. 20
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DefaultDynamicProxyHttpClientFactory.cs
  15. 58
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs
  16. 2
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/IDynamicProxyHttpClientFactory.cs
  17. 1
      samples/BookStore/src/Acme.BookStore.Web/Acme.BookStore.Web.csproj
  18. 1
      samples/BookStore/src/Acme.BookStore.Web/Program.cs
  19. 2
      samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductManagementApplicationAutoMapperProfile.cs

3
docs/en/AspNetCore/Tag-Helpers.md

@ -1,3 +0,0 @@
# Tag Helpers
TODO

3
docs/en/AspNetCore/Tag-Helpers/Dynamic-Forms.md

@ -0,0 +1,3 @@
## Dynamic Forms
This is not documented yet. You can see a [demo](http://bootstrap-taghelpers.abp.io/Components/DynamicForms) for now.

0
docs/en/Tag-Helpers.md → docs/en/AspNetCore/Tag-Helpers/Index.md

3
docs/en/Aspect-Oriented-Programming.md

@ -0,0 +1,3 @@
## Dynamic Proxying / Interceptors
TODO

3
docs/en/Caching.md

@ -0,0 +1,3 @@
# Caching
TODO

3
docs/en/CorrelationId.md

@ -0,0 +1,3 @@
# Correlation ID
TODO

3
docs/en/Data-Filtering.md

@ -0,0 +1,3 @@
# Data Filtering
TODO

3
docs/en/Specifications.md

@ -0,0 +1,3 @@
# Specifications
TODO!

2
docs/en/docs-nav.json

@ -218,7 +218,7 @@
},
{
"text": "Tag Helpers",
"path": "Tag-Helpers.md"
"path": "AspNetCore/Tag-Helpers/Index.md"
},
{
"text": "Theming",

9
framework/src/Volo.Abp.AspNetCore.TestBase/Volo/Abp/AspNetCore/TestBase/DynamicProxying/AspNetCoreTestDynamicProxyHttpClientFactory.cs

@ -8,15 +8,20 @@ namespace Volo.Abp.AspNetCore.TestBase.DynamicProxying
public class AspNetCoreTestDynamicProxyHttpClientFactory : IDynamicProxyHttpClientFactory, ITransientDependency
{
private readonly ITestServerAccessor _testServerAccessor;
private readonly IHttpClientFactory _httpClientFactory;
public AspNetCoreTestDynamicProxyHttpClientFactory(ITestServerAccessor testServerAccessor)
{
public AspNetCoreTestDynamicProxyHttpClientFactory(ITestServerAccessor testServerAccessor, IHttpClientFactory httpClientFactory) {
_testServerAccessor = testServerAccessor;
_httpClientFactory = httpClientFactory;
}
public HttpClient Create()
{
return _testServerAccessor.Server.CreateClient();
}
public HttpClient Create(string name) {
return Create();
}
}
}

2
framework/src/Volo.Abp.Http.Client.IdentityModel/Volo/Abp/Http/Client/IdentityModel/IdentityModelRemoteServiceHttpClientAuthenticator.cs

@ -28,7 +28,7 @@ namespace Volo.Abp.Http.Client.IdentityModel
var accessToken = await GetAccessTokenFromHttpContextOrNullAsync();
if (accessToken != null)
{
context.Client.SetBearerToken(accessToken);
context.Request.SetBearerToken(accessToken);
return;
}
}

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

@ -3,6 +3,7 @@ using System.Linq;
using System.Reflection;
using Castle.DynamicProxy;
using JetBrains.Annotations;
using Polly;
using Volo.Abp;
using Volo.Abp.Castle.DynamicProxy;
using Volo.Abp.Http.Client;
@ -105,6 +106,12 @@ namespace Microsoft.Extensions.DependencyInjection
{
options.HttpClientProxies[type] = new DynamicHttpClientProxyConfig(type, remoteServiceConfigurationName);
});
//use IHttpClientFactory and polly
services.AddHttpClient(remoteServiceConfigurationName)
.AddTransientHttpErrorPolicy(builder =>
// retry 3 times
builder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i))));
var interceptorType = typeof(DynamicHttpProxyInterceptor<>).MakeGenericType(type);
services.AddTransient(interceptorType);

3
framework/src/Volo.Abp.Http.Client/Volo.Abp.Http.Client.csproj

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\common.props" />
@ -15,6 +15,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="2.2.0" />
</ItemGroup>
<ItemGroup>

20
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DefaultDynamicProxyHttpClientFactory.cs

@ -1,13 +1,25 @@
using System.Net.Http;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Http.Client.DynamicProxying
namespace Volo.Abp.Http.Client.DynamicProxying
{
public class DefaultDynamicProxyHttpClientFactory : IDynamicProxyHttpClientFactory, ITransientDependency
public class DefaultDynamicProxyHttpClientFactory : IDynamicProxyHttpClientFactory, ITransientDependency
{
public HttpClient Create()
private readonly IHttpClientFactory _httpClientFactory;
public DefaultDynamicProxyHttpClientFactory(IHttpClientFactory httpClientFactory)
{
_httpClientFactory = httpClientFactory;
}
public HttpClient Create()
{
return _httpClientFactory.CreateClient();
}
public HttpClient Create(string name)
{
return new HttpClient();
return _httpClientFactory.CreateClient(name);
}
}
}

58
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs

@ -128,41 +128,41 @@ namespace Volo.Abp.Http.Client.DynamicProxying
private async Task<string> MakeRequestAsync(IAbpMethodInvocation invocation)
{
using (var client = HttpClientFactory.Create())
{
var clientConfig = ClientOptions.HttpClientProxies.GetOrDefault(typeof(TService)) ?? throw new AbpException($"Could not get DynamicHttpClientProxyConfig for {typeof(TService).FullName}.");
var remoteServiceConfig = RemoteServiceOptions.RemoteServices.GetConfigurationOrDefault(clientConfig.RemoteServiceName);
var clientConfig = ClientOptions.HttpClientProxies.GetOrDefault(typeof(TService)) ?? throw new AbpException($"Could not get DynamicHttpClientProxyConfig for {typeof(TService).FullName}.");
var remoteServiceConfig = RemoteServiceOptions.RemoteServices.GetConfigurationOrDefault(clientConfig.RemoteServiceName);
var action = await ApiDescriptionFinder.FindActionAsync(remoteServiceConfig.BaseUrl, typeof(TService), invocation.Method);
var apiVersion = GetApiVersionInfo(action);
var url = remoteServiceConfig.BaseUrl + UrlBuilder.GenerateUrlWithParameters(action, invocation.ArgumentsDictionary, apiVersion);
var client = HttpClientFactory.Create(clientConfig.RemoteServiceName);
var requestMessage = new HttpRequestMessage(action.GetHttpMethod(), url)
{
Content = RequestPayloadBuilder.BuildContent(action, invocation.ArgumentsDictionary, JsonSerializer, apiVersion)
};
AddHeaders(invocation, action, requestMessage, apiVersion);
await ClientAuthenticator.Authenticate(
new RemoteServiceHttpClientAuthenticateContext(
client,
requestMessage,
remoteServiceConfig,
clientConfig.RemoteServiceName
)
);
var action = await ApiDescriptionFinder.FindActionAsync(remoteServiceConfig.BaseUrl, typeof(TService), invocation.Method);
var apiVersion = GetApiVersionInfo(action);
var url = remoteServiceConfig.BaseUrl + UrlBuilder.GenerateUrlWithParameters(action, invocation.ArgumentsDictionary, apiVersion);
var response = await client.SendAsync(requestMessage, GetCancellationToken());
var requestMessage = new HttpRequestMessage(action.GetHttpMethod(), url)
{
Content = RequestPayloadBuilder.BuildContent(action, invocation.ArgumentsDictionary, JsonSerializer, apiVersion)
};
if (!response.IsSuccessStatusCode)
{
await ThrowExceptionForResponseAsync(response);
}
AddHeaders(invocation, action, requestMessage, apiVersion);
return await response.Content.ReadAsStringAsync();
await ClientAuthenticator.Authenticate(
new RemoteServiceHttpClientAuthenticateContext(
client,
requestMessage,
remoteServiceConfig,
clientConfig.RemoteServiceName
)
);
var response = await client.SendAsync(requestMessage, GetCancellationToken());
if (!response.IsSuccessStatusCode)
{
await ThrowExceptionForResponseAsync(response);
}
}
return await response.Content.ReadAsStringAsync();
}
private ApiVersionInfo GetApiVersionInfo(ActionApiDescriptionModel action)
{

2
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/IDynamicProxyHttpClientFactory.cs

@ -5,5 +5,7 @@ namespace Volo.Abp.Http.Client.DynamicProxying
public interface IDynamicProxyHttpClientFactory
{
HttpClient Create();
HttpClient Create(string name);
}
}

1
samples/BookStore/src/Acme.BookStore.Web/Acme.BookStore.Web.csproj

@ -4,6 +4,7 @@
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>

1
samples/BookStore/src/Acme.BookStore.Web/Program.cs

@ -43,6 +43,7 @@ namespace Acme.BookStore.Web
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseIIS()
.UseStartup<Startup>()
.UseSerilog()
.Build();

2
samples/MicroserviceDemo/modules/product/src/ProductManagement.Application/ProductManagement/ProductManagementApplicationAutoMapperProfile.cs

@ -6,7 +6,7 @@ namespace ProductManagement
{
public ProductManagementApplicationAutoMapperProfile()
{
CreateMap<Product, ProductDto>();
}
}
}
Loading…
Cancel
Save