diff --git a/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj b/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj
index 7540dd5..3f03677 100644
--- a/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.AspCoreApi/EasyMicroservices.Cores.AspCoreApi.csproj
@@ -4,7 +4,7 @@
netstandard2.1;net6.0;net7.0;net8.0
AnyCPU;x64;x86
EasyMicroservices
- 0.0.1.41
+ 0.0.1.42
asp core servces.
EasyMicroservices@gmail.com
core,cores,base,database,services,asp,aspnet
diff --git a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj
index 73dc5de..2607982 100644
--- a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/EasyMicroservices.Cores.AspEntityFrameworkCoreApi.csproj
@@ -4,7 +4,7 @@
net6.0;net7.0;net8.0
AnyCPU;x64;x86
EasyMicroservices
- 0.0.1.41
+ 0.0.1.42
asp core servces.
EasyMicroservices@gmail.com
core,cores,base,database,services,asp,aspnet,aspcore,efcore
diff --git a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs
index a568b69..8559edc 100644
--- a/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs
+++ b/src/CSharp/EasyMicroservices.Cores.AspEntityFrameworkCoreApi/StartUpExtensions.cs
@@ -1,9 +1,11 @@
-using EasyMicroservices.ContentsMicroservice.Clients.Helpers;
+using Contents.GeneratedServices;
+using EasyMicroservices.ContentsMicroservice.Clients.Helpers;
using EasyMicroservices.Cores.AspCoreApi.Authorizations;
using EasyMicroservices.Cores.AspCoreApi.Interfaces;
using EasyMicroservices.Cores.AspCoreApi.Managers;
using EasyMicroservices.Cores.AspEntityFrameworkCoreApi.Interfaces;
using EasyMicroservices.Cores.AspEntityFrameworkCoreApi.Middlewares;
+using EasyMicroservices.Cores.Clients;
using EasyMicroservices.Cores.Database.Interfaces;
using EasyMicroservices.Cores.Database.Logics;
using EasyMicroservices.Cores.Database.Managers;
@@ -14,6 +16,7 @@
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors.Infrastructure;
+using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
@@ -86,12 +89,29 @@ public static IServiceCollection Builder(this IServiceCollection servi
{
option.ExceptionHandler = AppAuthorizationMiddleware.ExceptionHandler;
});
- services.AddScoped(service => new Contents.GeneratedServices.ContentClient(GetContentAddress(service)?.Address, new HttpClient()));
+ services.AddScoped(service => GetContentClient(service));
services.AddScoped();
services.AddScoped();
return services;
}
+ static HttpClient ContentClientCttpClient = new HttpClient();
+ static T SetToken(IServiceProvider serviceProvider, T coreSwaggerClientBase)
+ where T : CoreSwaggerClientBase
+ {
+ var _httpContextAccessor = serviceProvider.GetService();
+ if (_httpContextAccessor?.HttpContext != null && _httpContextAccessor.HttpContext.Request.Headers.TryGetValue("Authorization", out var authorizationHeader))
+ {
+ coreSwaggerClientBase.SetBearerToken(authorizationHeader.ToString().Replace("Bearer ", ""));
+ }
+ return coreSwaggerClientBase;
+ }
+
+ static ContentClient GetContentClient(IServiceProvider serviceProvider)
+ {
+ return SetToken(serviceProvider, new Contents.GeneratedServices.ContentClient(GetContentAddress(serviceProvider)?.Address, ContentClientCttpClient));
+ }
+
///
///
///
@@ -143,7 +163,7 @@ public static IServiceCollection UseActivityChangeLog(this IServiceCollection se
}
- static void UseSwaggerUI(IConfiguration config,Func,IApplicationBuilder> swagger)
+ static void UseSwaggerUI(IConfiguration config, Func, IApplicationBuilder> swagger)
{
var ui = config.GetSection("Swagger:SwaggerUI").Get();
swagger(so =>
diff --git a/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj b/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj
index 278052a..d3a87a7 100644
--- a/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.Clients/EasyMicroservices.Cores.Clients.csproj
@@ -4,7 +4,7 @@
netstandard2.0;netstandard2.1;net6.0;net8.0
AnyCPU;x64;x86
EasyMicroservices
- 0.0.1.41
+ 0.0.1.42
core of database.
EasyMicroservices@gmail.com
core,cores,base,client,clients
diff --git a/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj b/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj
index 3e90d06..8689912 100644
--- a/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.Contracts/EasyMicroservices.Cores.Contracts.csproj
@@ -4,7 +4,7 @@
netstandard2.0;netstandard2.1;net45;net6.0;net8.0
AnyCPU;x64;x86
EasyMicroservices
- 0.0.1.41
+ 0.0.1.42
core contracts.
EasyMicroservices@gmail.com
core,cores,base,contract,contracts,dto,dtos
diff --git a/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj b/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj
index 87d7071..9a2c385 100644
--- a/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.Database/EasyMicroservices.Cores.Database.csproj
@@ -4,7 +4,7 @@
netstandard2.0;netstandard2.1;net45;net6.0;net8.0
AnyCPU;x64;x86
EasyMicroservices
- 0.0.1.41
+ 0.0.1.42
core of database.
EasyMicroservices@gmail.com
core,cores,base,database
diff --git a/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj b/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj
index 7d8907a..7f4cc03 100644
--- a/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.EntityFrameworkCore/EasyMicroservices.Cores.EntityFrameworkCore.csproj
@@ -4,7 +4,7 @@
netstandard2.1;net6.0;net8.0
AnyCPU;x64;x86
EasyMicroservices
- 0.0.1.41
+ 0.0.1.42
ef core of database.
EasyMicroservices@gmail.com
core,cores,base,database,ef,efcore
diff --git a/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj b/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj
index e19a87b..d28cba0 100644
--- a/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj
+++ b/src/CSharp/EasyMicroservices.Cores.Relational.EntityFrameworkCore/EasyMicroservices.Cores.Relational.EntityFrameworkCore.csproj
@@ -4,7 +4,7 @@
netstandard2.1;net6.0;net7.0;net8.0
AnyCPU;x64;x86
EasyMicroservices
- 0.0.1.41
+ 0.0.1.42
ef core of Relational database.
EasyMicroservices@gmail.com
core,cores,base,database,ef,efcore,Relational