resolve conflicts
This commit is contained in:
commit
ce2724af69
9
ServiceFabric/Linux/.dockerignore
Normal file
9
ServiceFabric/Linux/.dockerignore
Normal file
@ -0,0 +1,9 @@
|
||||
.dockerignore
|
||||
.env
|
||||
.git
|
||||
.gitignore
|
||||
.vs
|
||||
.vscode
|
||||
*/bin
|
||||
*/obj
|
||||
**/.toolstarget
|
@ -6,6 +6,8 @@
|
||||
<ServerGarbageCollection>True</ServerGarbageCollection>
|
||||
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
|
||||
<TargetLatestRuntimePatch>False</TargetLatestRuntimePatch>
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
<UserSecretsId>860c6d00-8a17-45b6-be76-28c2395d468e</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -16,6 +18,7 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.ServiceFabric.AspNetCore.Kestrel" Version="3.3.617" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.0.2105168" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -5,8 +5,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "marketing.api",
|
||||
"Port": 80
|
||||
"Host": "marketingapi.eshoponservicefabric",
|
||||
"Port": 5110
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/m/{everything}",
|
||||
@ -17,8 +17,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "locations.api",
|
||||
"Port": 80
|
||||
"Host": "locationsapi.eshoponservicefabric",
|
||||
"Port": 5109
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/l/{everything}",
|
||||
|
@ -5,8 +5,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "catalog.api",
|
||||
"Port": 80
|
||||
"Host": "catalogapi.eshoponservicefabric",
|
||||
"Port": 5101
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/c/{everything}",
|
||||
@ -17,8 +17,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "basket.api",
|
||||
"Port": 80
|
||||
"Host": "basketapi.eshoponservicefabric",
|
||||
"Port": 5103
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/b/{everything}",
|
||||
@ -33,8 +33,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "ordering.api",
|
||||
"Port": 80
|
||||
"Host": "orderingapi.eshoponservicefabric",
|
||||
"Port": 5102
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/o/{everything}",
|
||||
@ -49,8 +49,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "mobileshoppingagg",
|
||||
"Port": 80
|
||||
"Host": "mobileshoppingagg.eshoponservicefabric",
|
||||
"Port": 5120
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/{everything}",
|
||||
@ -65,8 +65,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "ordering.api",
|
||||
"Port": 80
|
||||
"Host": "orderingapi.eshoponservicefabric",
|
||||
"Port": 5102
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/orders-api/{everything}",
|
||||
@ -77,8 +77,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "basket.api",
|
||||
"Port": 80
|
||||
"Host": "basketapi.eshoponservicefabric",
|
||||
"Port": 5103
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/basket-api/{everything}",
|
||||
@ -89,8 +89,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "catalog.api",
|
||||
"Port": 80
|
||||
"Host": "catalogapi.eshoponservicefabric",
|
||||
"Port": 5101
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/catalog-api/{everything}",
|
||||
@ -101,8 +101,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "payment.api",
|
||||
"Port": 80
|
||||
"Host": "paymentapi.eshoponservicefabric",
|
||||
"Port": 5108
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/payment-api/{everything}",
|
||||
|
@ -5,8 +5,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "marketing.api",
|
||||
"Port": 80
|
||||
"Host": "marketingapi.eshoponservicefabric",
|
||||
"Port": 5110
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/m/{everything}",
|
||||
@ -17,8 +17,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "locations.api",
|
||||
"Port": 80
|
||||
"Host": "locationsapi.eshoponservicefabric",
|
||||
"Port": 5109
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/l/{everything}",
|
||||
|
@ -5,8 +5,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "catalog.api",
|
||||
"Port": 80
|
||||
"Host": "catalogapi.eshoponservicefabric",
|
||||
"Port": 5101
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/c/{everything}",
|
||||
@ -17,8 +17,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "basket.api",
|
||||
"Port": 80
|
||||
"Host": "basketapi.eshoponservicefabric",
|
||||
"Port": 5103
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/b/{everything}",
|
||||
@ -33,8 +33,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "ordering.api",
|
||||
"Port": 80
|
||||
"Host": "orderingapi.eshoponservicefabric",
|
||||
"Port": 5102
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/o/{everything}",
|
||||
@ -49,8 +49,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "webshoppingagg",
|
||||
"Port": 80
|
||||
"Host": "webshoppingagg.eshoponservicefabric",
|
||||
"Port": 5121
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/{everything}",
|
||||
@ -65,8 +65,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "ordering.api",
|
||||
"Port": 80
|
||||
"Host": "orderingapi.eshoponservicefabric",
|
||||
"Port": 5102
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/orders-api/{everything}",
|
||||
@ -77,7 +77,7 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "ordering.signalrhub",
|
||||
"Host": "ordering.signalrhub.eshoponservicefabric",
|
||||
"Port": 80
|
||||
}
|
||||
],
|
||||
@ -89,8 +89,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "basket.api",
|
||||
"Port": 80
|
||||
"Host": "basketapi.eshoponservicefabric",
|
||||
"Port": 5103
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/basket-api/{everything}",
|
||||
@ -101,8 +101,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "catalog.api",
|
||||
"Port": 80
|
||||
"Host": "catalogapi.eshoponservicefabric",
|
||||
"Port": 5101
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/catalog-api/{everything}",
|
||||
@ -113,8 +113,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "payment.api",
|
||||
"Port": 80
|
||||
"Host": "paymentapi.eshoponservicefabric",
|
||||
"Port": 5108
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/payment-api/{everything}",
|
||||
|
@ -11,20 +11,20 @@ namespace ApiGw_Base.Controllers
|
||||
public class ConfigurationController : ControllerBase
|
||||
{
|
||||
[HttpGet("mobile/marketing")]
|
||||
public IActionResult MobileMarketing() => ReadConfigurationFile(ConfigurationType.Mobile, ConfigurationBffType.Marketing);
|
||||
public IActionResult MobileMarketing() => ReadConfigurationFile(Channel.Mobile, ChannelType.Marketing);
|
||||
|
||||
[HttpGet("mobile/shopping")]
|
||||
public IActionResult MobileShopping() => ReadConfigurationFile(ConfigurationType.Mobile, ConfigurationBffType.Shopping);
|
||||
public IActionResult MobileShopping() => ReadConfigurationFile(Channel.Mobile, ChannelType.Shopping);
|
||||
|
||||
[HttpGet("web/marketing")]
|
||||
public IActionResult WebMarketing() => ReadConfigurationFile(ConfigurationType.Web, ConfigurationBffType.Marketing);
|
||||
public IActionResult WebMarketing() => ReadConfigurationFile(Channel.Web, ChannelType.Marketing);
|
||||
|
||||
[HttpGet("web/shopping")]
|
||||
public IActionResult WebShopping() => ReadConfigurationFile(ConfigurationType.Web, ConfigurationBffType.Shopping);
|
||||
public IActionResult WebShopping() => ReadConfigurationFile(Channel.Web, ChannelType.Shopping);
|
||||
|
||||
private IActionResult ReadConfigurationFile(ConfigurationType configurationType, ConfigurationBffType configurationBffType)
|
||||
private IActionResult ReadConfigurationFile(Channel channel, ChannelType channelType)
|
||||
{
|
||||
var path = $"{AppDomain.CurrentDomain.BaseDirectory}/Configurations/configuration.{configurationType}.Bff.{configurationBffType}.json";
|
||||
var path = $"{AppDomain.CurrentDomain.BaseDirectory}/Configurations/configuration.{channel}.Bff.{channelType}.json";
|
||||
|
||||
using (var streamReader = new StreamReader(path, Encoding.UTF8))
|
||||
{
|
||||
@ -32,7 +32,7 @@ namespace ApiGw_Base.Controllers
|
||||
|
||||
if (string.IsNullOrWhiteSpace(jsonString))
|
||||
{
|
||||
return BadRequest($"Configuration file 'configuration.{configurationType}.Bff.{configurationBffType}.json' not found");
|
||||
return BadRequest($"Configuration file 'configuration.{channel}.Bff.{channelType}.json' not found");
|
||||
}
|
||||
|
||||
return Ok(jsonString);
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace ApiGw_Base.Enums
|
||||
{
|
||||
public enum ConfigurationType
|
||||
public enum Channel
|
||||
{
|
||||
Web,
|
||||
Mobile
|
@ -1,6 +1,6 @@
|
||||
namespace ApiGw_Base.Enums
|
||||
{
|
||||
public enum ConfigurationBffType
|
||||
public enum ChannelType
|
||||
{
|
||||
Marketing,
|
||||
Shopping
|
@ -1,9 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric">
|
||||
<!-- Add your custom configuration sections and parameters here -->
|
||||
<!--
|
||||
<Section Name="MyConfigSection">
|
||||
<Parameter Name="MyParameter" Value="Value1" />
|
||||
</Section>
|
||||
-->
|
||||
<!--<Section Name="ServiceFabricSettings">
|
||||
<Parameter Name="UrlMobilMarketing" Value="configuration/mobile/marketing" />
|
||||
<Parameter Name="UrlMobilShopping" Value="/configuration/mobile/shopping" />
|
||||
<Parameter Name="UrlWebMarketing" Value="/configuration/web/marketing" />
|
||||
<Parameter Name="UrlWebShopping" Value="/configuration/web/shopping" />
|
||||
</Section>-->
|
||||
</Settings>
|
||||
|
@ -17,9 +17,18 @@
|
||||
<Program>ApiGw_Base.exe</Program>
|
||||
<WorkingFolder>CodePackage</WorkingFolder>
|
||||
</ExeHost>
|
||||
<!--<ContainerHost>
|
||||
<ImageName>eshop/sf.linux.settings.api:#{tag}#</ImageName>
|
||||
</ContainerHost>-->
|
||||
</EntryPoint>
|
||||
<EnvironmentVariables>
|
||||
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value=""/>
|
||||
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="Development"/>
|
||||
<EnvironmentVariable Name="ASPNETCORE_URLS" Value="http://0.0.0.0:80"/>
|
||||
<EnvironmentVariable Name="UrlMobilMarketing" Value="http://apigw_base.eshoponservicefabricapigwtype/configuration/mobile/marketing" />
|
||||
<EnvironmentVariable Name="UrlMobilShopping" Value="http://apigw_base.eshoponservicefabricapigwtype/configuration/mobile/shopping" />
|
||||
<EnvironmentVariable Name="UrlWebMarketing" Value="http://apigw_base.eshoponservicefabricapigwtype/configuration/web/marketing" />
|
||||
<EnvironmentVariable Name="UrlWebShopping" Value="http://apigw_base.eshoponservicefabricapigwtype/configuration/web/shopping" />
|
||||
<EnvironmentVariable Name="OrchestratorType" Value="SF"/>
|
||||
</EnvironmentVariables>
|
||||
</CodePackage>
|
||||
|
||||
@ -32,6 +41,7 @@
|
||||
<!-- This endpoint is used by the communication listener to obtain the port on which to
|
||||
listen. Please note that if your service is partitioned, this port is shared with
|
||||
replicas of different partitions that are placed in your code. -->
|
||||
<!--<Endpoint UriScheme="http" Name="sf.linux.settings.api.endpoint" Port="8912" />-->
|
||||
<Endpoint Protocol="https" Name="ServiceEndpoint" Type="Input" Port="8912" />
|
||||
</Endpoints>
|
||||
</Resources>
|
||||
|
@ -1,5 +1,4 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
@ -8,6 +7,7 @@
|
||||
"sslPort": 44363
|
||||
}
|
||||
},
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
@ -21,10 +21,15 @@
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "api/values",
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||
},
|
||||
"Docker": {
|
||||
"commandName": "Docker",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/api/values"
|
||||
}
|
||||
}
|
||||
}
|
@ -13,6 +13,11 @@
|
||||
<EnvironmentOverrides CodePackageRef="code">
|
||||
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="[ApiGw_Base_ASPNETCORE_ENVIRONMENT]" />
|
||||
</EnvironmentOverrides>
|
||||
<!--<Policies>
|
||||
<ContainerHostPolicies CodePackageRef="Code">
|
||||
<PortBinding ContainerPort="80" EndpointRef="sf.linux.settings.api.endpoint" />
|
||||
</ContainerHostPolicies>
|
||||
</Policies>-->
|
||||
</ServiceManifestImport>
|
||||
<DefaultServices>
|
||||
<!-- The section below creates instances of service types, when an instance of this
|
||||
@ -20,7 +25,7 @@
|
||||
ServiceFabric PowerShell module.
|
||||
|
||||
The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. -->
|
||||
<Service Name="ApiGw_Base" ServicePackageActivationMode="ExclusiveProcess">
|
||||
<Service Name="ApiGw_Base" ServiceDnsName="apigw_base.eshoponservicefabricapigwtype" ServicePackageActivationMode="ExclusiveProcess">
|
||||
<StatelessService ServiceTypeName="ApiGw_BaseType" InstanceCount="[ApiGw_Base_InstanceCount]">
|
||||
<SingletonPartition />
|
||||
</StatelessService>
|
||||
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<Settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric">
|
||||
<!-- Add your custom configuration sections and parameters here -->
|
||||
<!--
|
||||
<Section Name="MyConfigSection">
|
||||
<Parameter Name="MyParameter" Value="Value1" />
|
||||
</Section>
|
||||
-->
|
||||
</Settings>
|
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ServiceManifest Name="OrderingSignalrhubPkg"
|
||||
Version="1.0.0"
|
||||
xmlns="http://schemas.microsoft.com/2011/01/fabric"
|
||||
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<ServiceTypes>
|
||||
<!-- This is the name of your ServiceType.
|
||||
The UseImplicitHost attribute indicates this is a guest service. -->
|
||||
<StatelessServiceType ServiceTypeName="OrderingSignalrhubType" UseImplicitHost="true" />
|
||||
</ServiceTypes>
|
||||
|
||||
<!-- Code package is your service executable. -->
|
||||
<CodePackage Name="Code" Version="1.0.0">
|
||||
<EntryPoint>
|
||||
<!-- Follow this link for more information about deploying Windows containers to Service Fabric: https://aka.ms/sfguestcontainers -->
|
||||
<ContainerHost>
|
||||
<ImageName>eshop/ordering.signalrhub:#{tag}#</ImageName>
|
||||
</ContainerHost>
|
||||
</EntryPoint>
|
||||
<!-- Pass environment variables to your container: -->
|
||||
<!--
|
||||
<EnvironmentVariables>
|
||||
<EnvironmentVariable Name="VariableName" Value="VariableValue"/>
|
||||
</EnvironmentVariables>
|
||||
-->
|
||||
</CodePackage>
|
||||
|
||||
<!-- Config package is the contents of the Config directoy under PackageRoot that contains an
|
||||
independently-updateable and versioned set of custom configuration settings for your service. -->
|
||||
<ConfigPackage Name="Config" Version="1.0.0" />
|
||||
|
||||
<Resources>
|
||||
<Endpoints>
|
||||
<!-- This endpoint is used by the communication listener to obtain the port on which to
|
||||
listen. Please note that if your service is partitioned, this port is shared with
|
||||
replicas of different partitions that are placed in your code. -->
|
||||
<Endpoint Name="OrderingSignalrhubTypeEndpoint" Port="5112" />
|
||||
</Endpoints>
|
||||
</Resources>
|
||||
</ServiceManifest>
|
@ -5,8 +5,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "marketing.api",
|
||||
"Port": 80
|
||||
"Host": "marketingapi.eshoponservicefabric",
|
||||
"Port": 5110
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/m/{everything}",
|
||||
@ -17,8 +17,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "locations.api",
|
||||
"Port": 80
|
||||
"Host": "locationsapi.eshoponservicefabric",
|
||||
"Port": 5109
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/l/{everything}",
|
||||
|
@ -5,8 +5,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "catalog.api",
|
||||
"Port": 80
|
||||
"Host": "catalogapi.eshoponservicefabric",
|
||||
"Port": 5101
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/c/{everything}",
|
||||
@ -17,8 +17,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "basket.api",
|
||||
"Port": 80
|
||||
"Host": "basketapi.eshoponservicefabric",
|
||||
"Port": 5103
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/b/{everything}",
|
||||
@ -33,8 +33,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "ordering.api",
|
||||
"Port": 80
|
||||
"Host": "orderingapi.eshoponservicefabric",
|
||||
"Port": 5102
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/o/{everything}",
|
||||
@ -49,8 +49,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "mobileshoppingagg",
|
||||
"Port": 80
|
||||
"Host": "mobileshoppingagg.eshoponservicefabric",
|
||||
"Port": 5120
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/{everything}",
|
||||
@ -65,8 +65,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "ordering.api",
|
||||
"Port": 80
|
||||
"Host": "orderingapi.eshoponservicefabric",
|
||||
"Port": 5102
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/orders-api/{everything}",
|
||||
@ -77,8 +77,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "basket.api",
|
||||
"Port": 80
|
||||
"Host": "basketapi.eshoponservicefabric",
|
||||
"Port": 5103
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/basket-api/{everything}",
|
||||
@ -89,8 +89,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "catalog.api",
|
||||
"Port": 80
|
||||
"Host": "catalogapi.eshoponservicefabric",
|
||||
"Port": 5101
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/catalog-api/{everything}",
|
||||
@ -101,8 +101,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "payment.api",
|
||||
"Port": 80
|
||||
"Host": "paymentapi.eshoponservicefabric",
|
||||
"Port": 5108
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/payment-api/{everything}",
|
||||
|
@ -5,8 +5,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "marketing.api",
|
||||
"Port": 80
|
||||
"Host": "marketingapi.eshoponservicefabric",
|
||||
"Port": 5110
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/m/{everything}",
|
||||
@ -17,8 +17,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "locations.api",
|
||||
"Port": 80
|
||||
"Host": "locationsapi.eshoponservicefabric",
|
||||
"Port": 5109
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/l/{everything}",
|
||||
|
@ -5,8 +5,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "catalog.api",
|
||||
"Port": 80
|
||||
"Host": "catalogapi.eshoponservicefabric",
|
||||
"Port": 5101
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/c/{everything}",
|
||||
@ -17,8 +17,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "basket.api",
|
||||
"Port": 80
|
||||
"Host": "basketapi.eshoponservicefabric",
|
||||
"Port": 5103
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/b/{everything}",
|
||||
@ -33,8 +33,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "ordering.api",
|
||||
"Port": 80
|
||||
"Host": "orderingapi.eshoponservicefabric",
|
||||
"Port": 5102
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/api/{version}/o/{everything}",
|
||||
@ -49,8 +49,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "webshoppingagg",
|
||||
"Port": 80
|
||||
"Host": "webshoppingagg.eshoponservicefabric",
|
||||
"Port": 5121
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/{everything}",
|
||||
@ -65,8 +65,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "ordering.api",
|
||||
"Port": 80
|
||||
"Host": "orderingapi.eshoponservicefabric",
|
||||
"Port": 5102
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/orders-api/{everything}",
|
||||
@ -77,7 +77,7 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "ordering.signalrhub",
|
||||
"Host": "ordering.signalrhub.eshoponservicefabric",
|
||||
"Port": 80
|
||||
}
|
||||
],
|
||||
@ -89,8 +89,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "basket.api",
|
||||
"Port": 80
|
||||
"Host": "basketapi.eshoponservicefabric",
|
||||
"Port": 5103
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/basket-api/{everything}",
|
||||
@ -101,8 +101,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "catalog.api",
|
||||
"Port": 80
|
||||
"Host": "catalogapi.eshoponservicefabric",
|
||||
"Port": 5101
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/catalog-api/{everything}",
|
||||
@ -113,8 +113,8 @@
|
||||
"DownstreamScheme": "http",
|
||||
"DownstreamHostAndPorts": [
|
||||
{
|
||||
"Host": "payment.api",
|
||||
"Port": 80
|
||||
"Host": "paymentapi.eshoponservicefabric",
|
||||
"Port": 5108
|
||||
}
|
||||
],
|
||||
"UpstreamPathTemplate": "/payment-api/{everything}",
|
||||
|
@ -11,20 +11,20 @@ namespace ApiGw_Base.Controllers
|
||||
public class ConfigurationController : ControllerBase
|
||||
{
|
||||
[HttpGet("mobile/marketing")]
|
||||
public IActionResult MobileMarketing() => ReadConfigurationFile(ConfigurationType.Mobile, ConfigurationBffType.Marketing);
|
||||
public IActionResult MobileMarketing() => ReadConfigurationFile(Channel.Mobile, ChannelType.Marketing);
|
||||
|
||||
[HttpGet("mobile/shopping")]
|
||||
public IActionResult MobileShopping() => ReadConfigurationFile(ConfigurationType.Mobile, ConfigurationBffType.Shopping);
|
||||
public IActionResult MobileShopping() => ReadConfigurationFile(Channel.Mobile, ChannelType.Shopping);
|
||||
|
||||
[HttpGet("web/marketing")]
|
||||
public IActionResult WebMarketing() => ReadConfigurationFile(ConfigurationType.Web, ConfigurationBffType.Marketing);
|
||||
public IActionResult WebMarketing() => ReadConfigurationFile(Channel.Web, ChannelType.Marketing);
|
||||
|
||||
[HttpGet("web/shopping")]
|
||||
public IActionResult WebShopping() => ReadConfigurationFile(ConfigurationType.Web, ConfigurationBffType.Shopping);
|
||||
public IActionResult WebShopping() => ReadConfigurationFile(Channel.Web, ChannelType.Shopping);
|
||||
|
||||
private IActionResult ReadConfigurationFile(ConfigurationType configurationType, ConfigurationBffType configurationBffType)
|
||||
private IActionResult ReadConfigurationFile(Channel channel, ChannelType channelType)
|
||||
{
|
||||
var path = $"{AppDomain.CurrentDomain.BaseDirectory}/Configurations/configuration.{configurationType}.Bff.{configurationBffType}.json";
|
||||
var path = $"{AppDomain.CurrentDomain.BaseDirectory}/Configurations/configuration.{channel}.Bff.{channelType}.json";
|
||||
|
||||
using (var streamReader = new StreamReader(path, Encoding.UTF8))
|
||||
{
|
||||
@ -32,7 +32,7 @@ namespace ApiGw_Base.Controllers
|
||||
|
||||
if (string.IsNullOrWhiteSpace(jsonString))
|
||||
{
|
||||
return BadRequest($"Configuration file 'configuration.{configurationType}.Bff.{configurationBffType}.json' not found");
|
||||
return BadRequest($"Configuration file 'configuration.{channel}.Bff.{channelType}.json' not found");
|
||||
}
|
||||
|
||||
return Ok(jsonString);
|
||||
|
@ -1,6 +1,6 @@
|
||||
namespace ApiGw_Base.Enums
|
||||
{
|
||||
public enum ConfigurationType
|
||||
public enum Channel
|
||||
{
|
||||
Web,
|
||||
Mobile
|
@ -1,6 +1,6 @@
|
||||
namespace ApiGw_Base.Enums
|
||||
{
|
||||
public enum ConfigurationBffType
|
||||
public enum ChannelType
|
||||
{
|
||||
Marketing,
|
||||
Shopping
|
@ -19,7 +19,13 @@
|
||||
</ExeHost>
|
||||
</EntryPoint>
|
||||
<EnvironmentVariables>
|
||||
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value=""/>
|
||||
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="Development"/>
|
||||
<EnvironmentVariable Name="ASPNETCORE_URLS" Value="http://0.0.0.0:80"/>
|
||||
<EnvironmentVariable Name="UrlMobilMarketing" Value="http://apigw_base.eshoponservicefabricapigwtype:8949/configuration/mobile/marketing" />
|
||||
<EnvironmentVariable Name="UrlMobilShopping" Value="http://apigw_base.eshoponservicefabricapigwtype:8949/configuration/mobile/shopping" />
|
||||
<EnvironmentVariable Name="UrlWebMarketing" Value="http://apigw_base.eshoponservicefabricapigwtype:8949/configuration/web/marketing" />
|
||||
<EnvironmentVariable Name="UrlWebShopping" Value="http://apigw_base.eshoponservicefabricapigwtype:8949/configuration/web/shopping" />
|
||||
<EnvironmentVariable Name="OrchestratorType" Value="SF"/>
|
||||
</EnvironmentVariables>
|
||||
</CodePackage>
|
||||
|
||||
|
@ -12,6 +12,12 @@
|
||||
<ConfigOverrides />
|
||||
<EnvironmentOverrides CodePackageRef="code">
|
||||
<EnvironmentVariable Name="ASPNETCORE_ENVIRONMENT" Value="[ApiGw_Base_ASPNETCORE_ENVIRONMENT]" />
|
||||
<EnvironmentVariable Name="ASPNETCORE_URLS" Value="http://0.0.0.0:80" />
|
||||
<EnvironmentVariable Name="UrlMobilMarketing" Value="http://apigw_base.eshoponservicefabricapigwtype:8949/configuration/mobile/marketing" />
|
||||
<EnvironmentVariable Name="UrlMobilShopping" Value="http://apigw_base.eshoponservicefabricapigwtype:8949/configuration/mobile/shopping" />
|
||||
<EnvironmentVariable Name="UrlWebMarketing" Value="http://apigw_base.eshoponservicefabricapigwtype:8949/configuration/web/marketing" />
|
||||
<EnvironmentVariable Name="UrlWebShopping" Value="http://apigw_base.eshoponservicefabricapigwtype:8949/configuration/web/shopping" />
|
||||
<EnvironmentVariable Name="OrchestratorType" Value="SF" />
|
||||
</EnvironmentOverrides>
|
||||
</ServiceManifestImport>
|
||||
<DefaultServices>
|
||||
@ -20,7 +26,7 @@
|
||||
ServiceFabric PowerShell module.
|
||||
|
||||
The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. -->
|
||||
<Service Name="ApiGw_Base" ServicePackageActivationMode="ExclusiveProcess">
|
||||
<Service Name="ApiGw_Base" ServiceDnsName="apigw_base.eshoponservicefabricapigwtype" ServicePackageActivationMode="ExclusiveProcess">
|
||||
<StatelessService ServiceTypeName="ApiGw_BaseType" InstanceCount="[ApiGw_Base_InstanceCount]">
|
||||
<SingletonPartition />
|
||||
</StatelessService>
|
||||
|
@ -8,4 +8,7 @@
|
||||
-->
|
||||
<ClusterConnectionParameters />
|
||||
<ApplicationParameterFile Path="..\ApplicationParameters\Local.5Node.xml" />
|
||||
<UpgradeDeployment Mode="UnmonitoredAuto" Enabled="false">
|
||||
<Parameters UpgradeReplicaSetCheckTimeoutSec="1" Force="True" />
|
||||
</UpgradeDeployment>
|
||||
</PublishProfile>
|
@ -379,4 +379,3 @@ services:
|
||||
- UseLoadTest=${USE_LOADTEST:-False}
|
||||
ports:
|
||||
- "5100:80"
|
||||
|
||||
|
@ -304,4 +304,3 @@ services:
|
||||
ports:
|
||||
- "80" # Important: In a production environment your should remove the external port (5121) kept here for microservice debugging purposes.
|
||||
# The API Gateway redirects and access through the internal port (80).
|
||||
|
||||
|
@ -216,4 +216,3 @@ services:
|
||||
- webshoppingagg
|
||||
- webshoppingapigw
|
||||
- webmarketingapigw
|
||||
|
||||
|
8
src/ApiGateways/ApiGw-Base/Enums/OrchestratorType.cs
Normal file
8
src/ApiGateways/ApiGw-Base/Enums/OrchestratorType.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace OcelotApiGw.Enums
|
||||
{
|
||||
public enum OrchestratorType
|
||||
{
|
||||
K8S,
|
||||
SF
|
||||
}
|
||||
}
|
13
src/ApiGateways/ApiGw-Base/Models/ServiceFabricSettings.cs
Normal file
13
src/ApiGateways/ApiGw-Base/Models/ServiceFabricSettings.cs
Normal file
@ -0,0 +1,13 @@
|
||||
namespace OcelotApiGw.Models
|
||||
{
|
||||
public class ServiceFabricSettings
|
||||
{
|
||||
public string UrlMobilMarketing { get; set; }
|
||||
|
||||
public string UrlMobilShopping { get; set; }
|
||||
|
||||
public string UrlWebMarketing { get; set; }
|
||||
|
||||
public string UrlWebShopping { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using OcelotApiGw.Enums;
|
||||
|
||||
namespace OcelotApiGw.Orchestrators
|
||||
{
|
||||
public interface IOrchestratorStrategy
|
||||
{
|
||||
OrchestratorType OrchestratorType { get; }
|
||||
|
||||
IConfigurationBuilder ConfigureOrchestrator(IConfigurationBuilder builder);
|
||||
}
|
||||
}
|
12
src/ApiGateways/ApiGw-Base/Orchestrators/Kubernetes.cs
Normal file
12
src/ApiGateways/ApiGw-Base/Orchestrators/Kubernetes.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using OcelotApiGw.Enums;
|
||||
|
||||
namespace OcelotApiGw.Orchestrators
|
||||
{
|
||||
public class Kubernetes : IOrchestratorStrategy
|
||||
{
|
||||
public OrchestratorType OrchestratorType => OrchestratorType.K8S;
|
||||
|
||||
public IConfigurationBuilder ConfigureOrchestrator(IConfigurationBuilder builder) => builder;
|
||||
}
|
||||
}
|
30
src/ApiGateways/ApiGw-Base/Orchestrators/ServiceFabric.cs
Normal file
30
src/ApiGateways/ApiGw-Base/Orchestrators/ServiceFabric.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using OcelotApiGw.Enums;
|
||||
using OcelotApiGw.Providers;
|
||||
using OcelotApiGw.Services;
|
||||
|
||||
namespace OcelotApiGw.Orchestrators
|
||||
{
|
||||
public class ServiceFabric : IOrchestratorStrategy
|
||||
{
|
||||
private readonly ISettingService _settingService;
|
||||
|
||||
public ServiceFabric(ISettingService settingService)
|
||||
{
|
||||
_settingService = settingService;
|
||||
}
|
||||
|
||||
public OrchestratorType OrchestratorType => OrchestratorType.SF;
|
||||
|
||||
public IConfigurationBuilder ConfigureOrchestrator(IConfigurationBuilder builder)
|
||||
{
|
||||
var config = _settingService.GetConfiguration();
|
||||
|
||||
var memoryFileProvider = new InMemoryFileProvider(config);
|
||||
|
||||
builder.AddJsonFile(memoryFileProvider, string.Empty, false, false);
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Serilog;
|
||||
@ -16,24 +12,22 @@ namespace OcelotApiGw
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
BuildWebHost(args).Run();
|
||||
}
|
||||
|
||||
public static IWebHost BuildWebHost(string[] args)
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.ConfigureAppConfiguration((hostingContext, config) =>
|
||||
{
|
||||
IWebHostBuilder builder = WebHost.CreateDefaultBuilder(args);
|
||||
builder.ConfigureServices(s => s.AddSingleton(builder))
|
||||
.ConfigureAppConfiguration(ic => ic.AddJsonFile(Path.Combine("configuration", "configuration.json")))
|
||||
.UseStartup<Startup>()
|
||||
config.SetBasePath(Directory.GetCurrentDirectory());
|
||||
config.AddJsonFile(Path.Combine("configuration", "configuration.json"));
|
||||
config.AddCommandLine(args);
|
||||
})
|
||||
.UseSerilog((builderContext, config) =>
|
||||
{
|
||||
config
|
||||
.MinimumLevel.Information()
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Console();
|
||||
});
|
||||
IWebHost host = builder.Build();
|
||||
return host;
|
||||
})
|
||||
.Build()
|
||||
.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
28
src/ApiGateways/ApiGw-Base/Providers/InMemoryFile.cs
Normal file
28
src/ApiGateways/ApiGw-Base/Providers/InMemoryFile.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace OcelotApiGw.Providers
|
||||
{
|
||||
public class InMemoryFile : IFileInfo
|
||||
{
|
||||
private readonly byte[] _data;
|
||||
|
||||
public InMemoryFile(string data) => _data = Encoding.UTF8.GetBytes(data);
|
||||
|
||||
public Stream CreateReadStream() => new MemoryStream(_data);
|
||||
|
||||
public bool Exists { get; } = true;
|
||||
|
||||
public long Length => _data.Length;
|
||||
|
||||
public string PhysicalPath { get; } = string.Empty;
|
||||
|
||||
public string Name { get; } = string.Empty;
|
||||
|
||||
public DateTimeOffset LastModified { get; } = DateTimeOffset.UtcNow;
|
||||
|
||||
public bool IsDirectory { get; } = false;
|
||||
}
|
||||
}
|
18
src/ApiGateways/ApiGw-Base/Providers/InMemoryFileProvider.cs
Normal file
18
src/ApiGateways/ApiGw-Base/Providers/InMemoryFileProvider.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.Extensions.Primitives;
|
||||
|
||||
namespace OcelotApiGw.Providers
|
||||
{
|
||||
public class InMemoryFileProvider : IFileProvider
|
||||
{
|
||||
private readonly IFileInfo _fileInfo;
|
||||
|
||||
public InMemoryFileProvider(string data) => _fileInfo = new InMemoryFile(data);
|
||||
|
||||
public IFileInfo GetFileInfo(string subpath) => _fileInfo;
|
||||
|
||||
public IDirectoryContents GetDirectoryContents(string subpath) => null;
|
||||
|
||||
public IChangeToken Watch(string filter) => NullChangeToken.Singleton;
|
||||
}
|
||||
}
|
7
src/ApiGateways/ApiGw-Base/Services/ISettingService.cs
Normal file
7
src/ApiGateways/ApiGw-Base/Services/ISettingService.cs
Normal file
@ -0,0 +1,7 @@
|
||||
namespace OcelotApiGw.Services
|
||||
{
|
||||
public interface ISettingService
|
||||
{
|
||||
string GetConfiguration();
|
||||
}
|
||||
}
|
51
src/ApiGateways/ApiGw-Base/Services/SettingService.cs
Normal file
51
src/ApiGateways/ApiGw-Base/Services/SettingService.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
using OcelotApiGw.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OcelotApiGw.Services
|
||||
{
|
||||
public class SettingService : ISettingService
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly ServiceFabricSettings _serviceFabricSettings;
|
||||
|
||||
public SettingService(HttpClient httpClient, IOptions<ServiceFabricSettings> serviceFabricSettings)
|
||||
{
|
||||
_httpClient = httpClient;
|
||||
_serviceFabricSettings = serviceFabricSettings.Value;
|
||||
}
|
||||
|
||||
public string GetConfiguration()
|
||||
{
|
||||
var strings = new List<string>();
|
||||
|
||||
var tasks = new Func<Task>[]
|
||||
{
|
||||
async () => {
|
||||
var configuration = await _httpClient.GetStringAsync(_serviceFabricSettings.UrlMobilMarketing);
|
||||
strings.Add(configuration);
|
||||
},
|
||||
async () => {
|
||||
var configuration = await _httpClient.GetStringAsync(_serviceFabricSettings.UrlMobilShopping);
|
||||
strings.Add(configuration);
|
||||
},
|
||||
async () => {
|
||||
var configuration = await _httpClient.GetStringAsync(_serviceFabricSettings.UrlWebMarketing);
|
||||
strings.Add(configuration);
|
||||
},
|
||||
async () => {
|
||||
var configuration = await _httpClient.GetStringAsync(_serviceFabricSettings.UrlWebShopping);
|
||||
strings.Add(configuration);
|
||||
}
|
||||
};
|
||||
|
||||
Task.WaitAll(tasks.Select(task => task()).ToArray());
|
||||
|
||||
return string.Join(',', strings);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,84 +1,90 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using HealthChecks.UI.Client;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Ocelot.DependencyInjection;
|
||||
using Ocelot.Middleware;
|
||||
using OcelotApiGw.Enums;
|
||||
using OcelotApiGw.Models;
|
||||
using OcelotApiGw.Orchestrators;
|
||||
using OcelotApiGw.Providers;
|
||||
using OcelotApiGw.Services;
|
||||
using System;
|
||||
using HealthChecks.UI.Client;
|
||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
||||
using System.Linq;
|
||||
|
||||
namespace OcelotApiGw
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
private readonly IConfiguration _cfg;
|
||||
private IConfiguration _configuration;
|
||||
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
_cfg = configuration;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
var identityUrl = _cfg.GetValue<string>("IdentityUrl");
|
||||
var identityUrl = _configuration.GetValue<string>("IdentityUrl");
|
||||
var authenticationProviderKey = "IdentityApiKey";
|
||||
|
||||
services.AddHealthChecks()
|
||||
.AddCheck("self", () => HealthCheckResult.Healthy())
|
||||
.AddUrlGroup(new Uri(_cfg["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" })
|
||||
.AddUrlGroup(new Uri(_cfg["OrderingUrlHC"]), name: "orderingapi-check", tags: new string[] { "orderingapi" })
|
||||
.AddUrlGroup(new Uri(_cfg["BasketUrlHC"]), name: "basketapi-check", tags: new string[] { "basketapi" })
|
||||
.AddUrlGroup(new Uri(_cfg["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" })
|
||||
.AddUrlGroup(new Uri(_cfg["MarketingUrlHC"]), name: "marketingapi-check", tags: new string[] { "marketingapi" })
|
||||
.AddUrlGroup(new Uri(_cfg["PaymentUrlHC"]), name: "paymentapi-check", tags: new string[] { "paymentapi" })
|
||||
.AddUrlGroup(new Uri(_cfg["LocationUrlHC"]), name: "locationapi-check", tags: new string[] { "locationapi" });
|
||||
.AddUrlGroup(new Uri(_configuration["CatalogUrlHC"]), name: "catalogapi-check", tags: new string[] { "catalogapi" })
|
||||
.AddUrlGroup(new Uri(_configuration["OrderingUrlHC"]), name: "orderingapi-check", tags: new string[] { "orderingapi" })
|
||||
.AddUrlGroup(new Uri(_configuration["BasketUrlHC"]), name: "basketapi-check", tags: new string[] { "basketapi" })
|
||||
.AddUrlGroup(new Uri(_configuration["IdentityUrlHC"]), name: "identityapi-check", tags: new string[] { "identityapi" })
|
||||
.AddUrlGroup(new Uri(_configuration["MarketingUrlHC"]), name: "marketingapi-check", tags: new string[] { "marketingapi" })
|
||||
.AddUrlGroup(new Uri(_configuration["PaymentUrlHC"]), name: "paymentapi-check", tags: new string[] { "paymentapi" })
|
||||
.AddUrlGroup(new Uri(_configuration["LocationUrlHC"]), name: "locationapi-check", tags: new string[] { "locationapi" });
|
||||
|
||||
services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("CorsPolicy",
|
||||
builder => builder
|
||||
options.AddPolicy("CorsPolicy", builder =>
|
||||
builder.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.SetIsOriginAllowed((host) => true)
|
||||
.AllowCredentials());
|
||||
});
|
||||
|
||||
services.AddAuthentication()
|
||||
.AddJwtBearer(authenticationProviderKey, x =>
|
||||
})
|
||||
.AddTransient<IOrchestratorStrategy, Kubernetes>()
|
||||
.AddTransient<IOrchestratorStrategy, ServiceFabric>()
|
||||
.AddTransient<IFileProvider, InMemoryFileProvider>()
|
||||
.AddAuthentication()
|
||||
.AddJwtBearer(authenticationProviderKey, options =>
|
||||
{
|
||||
x.Authority = identityUrl;
|
||||
x.RequireHttpsMetadata = false;
|
||||
x.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters()
|
||||
options.Authority = identityUrl;
|
||||
options.RequireHttpsMetadata = false;
|
||||
options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters()
|
||||
{
|
||||
ValidAudiences = new[] { "orders", "basket", "locations", "marketing", "mobileshoppingagg", "webshoppingagg" }
|
||||
};
|
||||
x.Events = new Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerEvents()
|
||||
{
|
||||
OnAuthenticationFailed = async ctx =>
|
||||
{
|
||||
int i = 0;
|
||||
},
|
||||
OnTokenValidated = async ctx =>
|
||||
{
|
||||
int i = 0;
|
||||
},
|
||||
|
||||
OnMessageReceived = async ctx =>
|
||||
{
|
||||
int i = 0;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
services.AddOcelot(_cfg);
|
||||
services.Configure<ServiceFabricSettings>(_configuration);
|
||||
services.AddHttpClient<ISettingService, SettingService>();
|
||||
|
||||
var orchestratorType = _configuration.GetValue<OrchestratorType>("OrchestratorType");
|
||||
|
||||
var config = new ConfigurationBuilder()
|
||||
.AddConfiguration(_configuration);
|
||||
|
||||
_configuration = services.BuildServiceProvider()
|
||||
.GetServices<IOrchestratorStrategy>()
|
||||
.Single(strategy => strategy.OrchestratorType == orchestratorType)
|
||||
.ConfigureOrchestrator(config)
|
||||
.Build();
|
||||
|
||||
services.AddOcelot(_configuration);
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
||||
{
|
||||
var pathBase = _cfg["PATH_BASE"];
|
||||
var pathBase = _configuration.GetValue<string>("PATH_BASE");
|
||||
|
||||
if (!string.IsNullOrEmpty(pathBase))
|
||||
{
|
||||
@ -101,11 +107,13 @@ namespace OcelotApiGw
|
||||
Predicate = r => r.Name.Contains("self")
|
||||
});
|
||||
|
||||
loggerFactory.AddConsole(_cfg.GetSection("Logging"));
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
loggerFactory.AddConsole(_configuration.GetSection("Logging"));
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
|
||||
app.UseCors("CorsPolicy");
|
||||
|
||||
app.UseOcelot().Wait();
|
||||
app.UseCors("CorsPolicy")
|
||||
.UseOcelot()
|
||||
.Wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,9 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
|
||||
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="2.1.0" />
|
||||
<PackageReference Include="IdentityServer4.EntityFramework" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Redis" Version="0.3.3" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.Redis" Version="2.2.0-preview2-35157" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="1.0.163" />
|
||||
</ItemGroup>
|
||||
|
@ -27,4 +27,9 @@
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
|
||||
<ProjectReference Include="..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
x
Reference in New Issue
Block a user