mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
commit
0af49617ee
29
.circleci/config.yml
Normal file
29
.circleci/config.yml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
version: 2.1
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
docker:
|
||||||
|
- image: mijitt0m/ocelot-build:0.0.1
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run: make build
|
||||||
|
release:
|
||||||
|
docker:
|
||||||
|
- image: mijitt0m/ocelot-build:0.0.1
|
||||||
|
steps:
|
||||||
|
- checkout
|
||||||
|
- run: make release
|
||||||
|
workflows:
|
||||||
|
version: 2
|
||||||
|
master:
|
||||||
|
jobs:
|
||||||
|
- release:
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
only: master
|
||||||
|
pr:
|
||||||
|
jobs:
|
||||||
|
- build:
|
||||||
|
filters:
|
||||||
|
branches:
|
||||||
|
ignore:
|
||||||
|
- master
|
31
.travis.yml
31
.travis.yml
@ -1,31 +0,0 @@
|
|||||||
language: csharp
|
|
||||||
os:
|
|
||||||
- osx
|
|
||||||
- linux
|
|
||||||
|
|
||||||
# Ubuntu 14.04
|
|
||||||
sudo: required
|
|
||||||
dist: bionic
|
|
||||||
|
|
||||||
# OS X 10.12
|
|
||||||
osx_image: xcode9.4
|
|
||||||
|
|
||||||
mono:
|
|
||||||
- 6.0.0
|
|
||||||
|
|
||||||
dotnet: 3.0.100
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags
|
|
||||||
- git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
|
||||||
- git fetch origin
|
|
||||||
|
|
||||||
script:
|
|
||||||
- ./build.sh
|
|
||||||
|
|
||||||
cache:
|
|
||||||
directories:
|
|
||||||
- .packages
|
|
||||||
- tools/Addins
|
|
||||||
- tools/gitreleasemanager
|
|
||||||
- tools/GitVersion.CommandLine
|
|
@ -1,7 +1,6 @@
|
|||||||
<Project>
|
<Project>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
|
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<RepositoryUrl>https://github.com/ThreeMammals/Ocelot</RepositoryUrl>
|
<RepositoryUrl>https://github.com/ThreeMammals/Ocelot</RepositoryUrl>
|
||||||
<!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
|
<!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
|
||||||
@ -11,6 +10,6 @@
|
|||||||
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All"/>
|
<!-- <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/> -->
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
20
Makefile
Normal file
20
Makefile
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
NAME ?= ocelot
|
||||||
|
|
||||||
|
build:
|
||||||
|
./build.sh
|
||||||
|
|
||||||
|
build_and_run_tests:
|
||||||
|
./build.sh --target=RunTests
|
||||||
|
|
||||||
|
release:
|
||||||
|
./build.sh --target=Release
|
||||||
|
|
||||||
|
run_acceptance_tests:
|
||||||
|
./build.sh --target=RunAcceptanceTests
|
||||||
|
|
||||||
|
run_benchmarks:
|
||||||
|
./build.sh --target=RunBenchmarkTests
|
||||||
|
|
||||||
|
run_unit_tests:
|
||||||
|
./build.sh --target=RunUnitTests
|
||||||
|
|
99
Ocelot.sln
99
Ocelot.sln
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio 15
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 15.0.27130.2036
|
VisualStudioVersion = 16.0.29613.14
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5CFB79B7-C9DC-45A4-9A75-625D92471702}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5CFB79B7-C9DC-45A4-9A75-625D92471702}"
|
||||||
EndProject
|
EndProject
|
||||||
@ -9,23 +9,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
.dockerignore = .dockerignore
|
.dockerignore = .dockerignore
|
||||||
.gitignore = .gitignore
|
.gitignore = .gitignore
|
||||||
build-and-release-unstable.ps1 = build-and-release-unstable.ps1
|
|
||||||
build-and-run-tests.ps1 = build-and-run-tests.ps1
|
|
||||||
build.cake = build.cake
|
build.cake = build.cake
|
||||||
build.ps1 = build.ps1
|
build.ps1 = build.ps1
|
||||||
codeanalysis.ruleset = codeanalysis.ruleset
|
codeanalysis.ruleset = codeanalysis.ruleset
|
||||||
docker-compose.yaml = docker-compose.yaml
|
|
||||||
Dockerfile = Dockerfile
|
|
||||||
GitVersion.yml = GitVersion.yml
|
GitVersion.yml = GitVersion.yml
|
||||||
global.json = global.json
|
|
||||||
LICENSE.md = LICENSE.md
|
LICENSE.md = LICENSE.md
|
||||||
README.md = README.md
|
README.md = README.md
|
||||||
release.ps1 = release.ps1
|
|
||||||
ReleaseNotes.md = ReleaseNotes.md
|
ReleaseNotes.md = ReleaseNotes.md
|
||||||
run-acceptance-tests.ps1 = run-acceptance-tests.ps1
|
|
||||||
run-benchmarks.ps1 = run-benchmarks.ps1
|
|
||||||
run-unit-tests.ps1 = run-unit-tests.ps1
|
|
||||||
version.ps1 = version.ps1
|
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{5B401523-36DA-4491-B73A-7590A26E420B}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{5B401523-36DA-4491-B73A-7590A26E420B}"
|
||||||
@ -56,7 +46,39 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ocelot.Provider.Rafty", "sr
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ocelot.Tracing.Butterfly", "src\Ocelot.Tracing.Butterfly\Ocelot.Tracing.Butterfly.csproj", "{6045E23D-669C-4F27-AF8E-8EEE6DB3557F}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ocelot.Tracing.Butterfly", "src\Ocelot.Tracing.Butterfly\Ocelot.Tracing.Butterfly.csproj", "{6045E23D-669C-4F27-AF8E-8EEE6DB3557F}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ocelot.Provider.Kubernetes", "src\Ocelot.Provider.Kubernetes\Ocelot.Provider.Kubernetes.csproj", "{72C8E528-B4F5-45CE-8A06-CD3787364856}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ocelot.Provider.Kubernetes", "src\Ocelot.Provider.Kubernetes\Ocelot.Provider.Kubernetes.csproj", "{72C8E528-B4F5-45CE-8A06-CD3787364856}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{8FA0CBA0-0338-48EB-B37F-83CA5022237C}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OcelotBasic", "samples\OcelotBasic\OcelotBasic.csproj", "{ED0B3A09-112B-4BA4-82D6-11569BC7A99B}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AdministrationApi", "samples\AdministrationApi\AdministrationApi.csproj", "{B180F8AE-2F8F-44F9-9E5D-FE65B84B742E}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OcelotGraphQL", "samples\OcelotGraphQL\OcelotGraphQL.csproj", "{F43429C3-EC49-464F-9423-9118A36E8FE3}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "eureka", "eureka", "{F1CF6F06-5A34-4A6A-8C19-003A78AB0DCF}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiGateway", "samples\OcelotEureka\ApiGateway\ApiGateway.csproj", "{48B3DD3C-7F4D-40C1-A104-3BF9EF4ACE29}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DownstreamService", "samples\OcelotEureka\DownstreamService\DownstreamService.csproj", "{32ADF9B3-CBFA-4607-8A8E-1532D90A7197}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "k8s", "k8s", "{4B706988-4817-43A8-ABE1-32A67998C2C8}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiGateway", "samples\OcelotKube\ApiGateway\ApiGateway.csproj", "{8500055B-2C51-4CF1-A6EE-F05BB3E9BF16}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DownstreamService", "samples\OcelotKube\DownstreamService\DownstreamService.csproj", "{7B319B8C-8155-4779-BD93-5ABD05CA2AB6}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "service-fabric", "service-fabric", "{B412628F-C325-47E1-A8D9-873DE04C8AF5}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OcelotApplicationApiGateway", "samples\OcelotServiceFabric\src\OcelotApplicationApiGateway\OcelotApplicationApiGateway.csproj", "{8E6DAE6E-E9B1-433A-80C3-1E2640FBA590}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OcelotApplicationService", "samples\OcelotServiceFabric\src\OcelotApplicationService\OcelotApplicationService.csproj", "{33BE6D88-F188-4E60-83AC-3C4B94D24675}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "administration", "administration", "{1F1F324D-6EA4-4E63-A6A7-C6053F412F1A}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "basic", "basic", "{ED066001-BAF7-4117-9884-DF591A56347D}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "graphql", "graphql", "{C15CD120-5F8D-41DE-9B21-00E3EA77D6C1}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -120,6 +142,42 @@ Global
|
|||||||
{72C8E528-B4F5-45CE-8A06-CD3787364856}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{72C8E528-B4F5-45CE-8A06-CD3787364856}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{72C8E528-B4F5-45CE-8A06-CD3787364856}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{72C8E528-B4F5-45CE-8A06-CD3787364856}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{72C8E528-B4F5-45CE-8A06-CD3787364856}.Release|Any CPU.Build.0 = Release|Any CPU
|
{72C8E528-B4F5-45CE-8A06-CD3787364856}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{ED0B3A09-112B-4BA4-82D6-11569BC7A99B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{ED0B3A09-112B-4BA4-82D6-11569BC7A99B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{ED0B3A09-112B-4BA4-82D6-11569BC7A99B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{ED0B3A09-112B-4BA4-82D6-11569BC7A99B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B180F8AE-2F8F-44F9-9E5D-FE65B84B742E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B180F8AE-2F8F-44F9-9E5D-FE65B84B742E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B180F8AE-2F8F-44F9-9E5D-FE65B84B742E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B180F8AE-2F8F-44F9-9E5D-FE65B84B742E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F43429C3-EC49-464F-9423-9118A36E8FE3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F43429C3-EC49-464F-9423-9118A36E8FE3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F43429C3-EC49-464F-9423-9118A36E8FE3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F43429C3-EC49-464F-9423-9118A36E8FE3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{48B3DD3C-7F4D-40C1-A104-3BF9EF4ACE29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{48B3DD3C-7F4D-40C1-A104-3BF9EF4ACE29}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{48B3DD3C-7F4D-40C1-A104-3BF9EF4ACE29}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{48B3DD3C-7F4D-40C1-A104-3BF9EF4ACE29}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{32ADF9B3-CBFA-4607-8A8E-1532D90A7197}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{32ADF9B3-CBFA-4607-8A8E-1532D90A7197}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{32ADF9B3-CBFA-4607-8A8E-1532D90A7197}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{32ADF9B3-CBFA-4607-8A8E-1532D90A7197}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{8500055B-2C51-4CF1-A6EE-F05BB3E9BF16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8500055B-2C51-4CF1-A6EE-F05BB3E9BF16}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8500055B-2C51-4CF1-A6EE-F05BB3E9BF16}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{8500055B-2C51-4CF1-A6EE-F05BB3E9BF16}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{7B319B8C-8155-4779-BD93-5ABD05CA2AB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{7B319B8C-8155-4779-BD93-5ABD05CA2AB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{7B319B8C-8155-4779-BD93-5ABD05CA2AB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{7B319B8C-8155-4779-BD93-5ABD05CA2AB6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{8E6DAE6E-E9B1-433A-80C3-1E2640FBA590}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8E6DAE6E-E9B1-433A-80C3-1E2640FBA590}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8E6DAE6E-E9B1-433A-80C3-1E2640FBA590}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{8E6DAE6E-E9B1-433A-80C3-1E2640FBA590}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{33BE6D88-F188-4E60-83AC-3C4B94D24675}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{33BE6D88-F188-4E60-83AC-3C4B94D24675}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{33BE6D88-F188-4E60-83AC-3C4B94D24675}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{33BE6D88-F188-4E60-83AC-3C4B94D24675}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -139,6 +197,21 @@ Global
|
|||||||
{AC153C67-EF18-47E6-A230-F0D3CF5F0A98} = {5CFB79B7-C9DC-45A4-9A75-625D92471702}
|
{AC153C67-EF18-47E6-A230-F0D3CF5F0A98} = {5CFB79B7-C9DC-45A4-9A75-625D92471702}
|
||||||
{6045E23D-669C-4F27-AF8E-8EEE6DB3557F} = {5CFB79B7-C9DC-45A4-9A75-625D92471702}
|
{6045E23D-669C-4F27-AF8E-8EEE6DB3557F} = {5CFB79B7-C9DC-45A4-9A75-625D92471702}
|
||||||
{72C8E528-B4F5-45CE-8A06-CD3787364856} = {5CFB79B7-C9DC-45A4-9A75-625D92471702}
|
{72C8E528-B4F5-45CE-8A06-CD3787364856} = {5CFB79B7-C9DC-45A4-9A75-625D92471702}
|
||||||
|
{ED0B3A09-112B-4BA4-82D6-11569BC7A99B} = {ED066001-BAF7-4117-9884-DF591A56347D}
|
||||||
|
{B180F8AE-2F8F-44F9-9E5D-FE65B84B742E} = {1F1F324D-6EA4-4E63-A6A7-C6053F412F1A}
|
||||||
|
{F43429C3-EC49-464F-9423-9118A36E8FE3} = {C15CD120-5F8D-41DE-9B21-00E3EA77D6C1}
|
||||||
|
{F1CF6F06-5A34-4A6A-8C19-003A78AB0DCF} = {8FA0CBA0-0338-48EB-B37F-83CA5022237C}
|
||||||
|
{48B3DD3C-7F4D-40C1-A104-3BF9EF4ACE29} = {F1CF6F06-5A34-4A6A-8C19-003A78AB0DCF}
|
||||||
|
{32ADF9B3-CBFA-4607-8A8E-1532D90A7197} = {F1CF6F06-5A34-4A6A-8C19-003A78AB0DCF}
|
||||||
|
{4B706988-4817-43A8-ABE1-32A67998C2C8} = {8FA0CBA0-0338-48EB-B37F-83CA5022237C}
|
||||||
|
{8500055B-2C51-4CF1-A6EE-F05BB3E9BF16} = {4B706988-4817-43A8-ABE1-32A67998C2C8}
|
||||||
|
{7B319B8C-8155-4779-BD93-5ABD05CA2AB6} = {4B706988-4817-43A8-ABE1-32A67998C2C8}
|
||||||
|
{B412628F-C325-47E1-A8D9-873DE04C8AF5} = {8FA0CBA0-0338-48EB-B37F-83CA5022237C}
|
||||||
|
{8E6DAE6E-E9B1-433A-80C3-1E2640FBA590} = {B412628F-C325-47E1-A8D9-873DE04C8AF5}
|
||||||
|
{33BE6D88-F188-4E60-83AC-3C4B94D24675} = {B412628F-C325-47E1-A8D9-873DE04C8AF5}
|
||||||
|
{1F1F324D-6EA4-4E63-A6A7-C6053F412F1A} = {8FA0CBA0-0338-48EB-B37F-83CA5022237C}
|
||||||
|
{ED066001-BAF7-4117-9884-DF591A56347D} = {8FA0CBA0-0338-48EB-B37F-83CA5022237C}
|
||||||
|
{C15CD120-5F8D-41DE-9B21-00E3EA77D6C1} = {8FA0CBA0-0338-48EB-B37F-83CA5022237C}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {21476EFF-778A-4F97-8A56-D1AF1CEC0C48}
|
SolutionGuid = {21476EFF-778A-4F97-8A56-D1AF1CEC0C48}
|
||||||
|
12
README.md
12
README.md
@ -1,14 +1,10 @@
|
|||||||
[<img src="https://threemammals.com/ocelot_logo.png">](https://threemammals.com/ocelot)
|
[<img src="https://threemammals.com/ocelot_logo.png">](https://threemammals.com/ocelot)
|
||||||
|
|
||||||
[](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb) Windows (AppVeyor)
|
[](https://circleci.com/gh/ThreeMammals/Ocelot/tree/master)
|
||||||
|
|
||||||
[](https://travis-ci.org/ThreeMammals/Ocelot) Linux & OSX (Travis)
|
|
||||||
|
|
||||||
[](https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb/history?branch=develop)
|
|
||||||
|
|
||||||
[](https://coveralls.io/github/ThreeMammals/Ocelot?branch=develop)
|
|
||||||
|
|
||||||
|
[](https://coveralls.io/github/ThreeMammals/Ocelot?branch=master)
|
||||||
|
|
||||||
|
[Slack](threemammals.slack.com)
|
||||||
|
|
||||||
# Ocelot
|
# Ocelot
|
||||||
|
|
||||||
@ -59,7 +55,7 @@ A quick list of Ocelot's capabilities for more information see the [documentatio
|
|||||||
|
|
||||||
## How to install
|
## How to install
|
||||||
|
|
||||||
Ocelot is designed to work with ASP.NET Core only and it targets `netstandard2.0`. This means it can be used anywhere `.NET Standard 2.0` is supported, including `.NET Core 2.1` and `.NET Framework 4.7.2` and up. [This](https://docs.microsoft.com/en-us/dotnet/standard/net-standard) documentation may prove helpful when working out if Ocelot would be suitable for you.
|
Ocelot is designed to work with ASP.NET Core only and it targets `netstandard2.0`. This means it can be used anywhere `.NET Standard 2.0` is supported, including `.NET Core 3.1` and `.NET Framework 4.8` and up. [This](https://docs.microsoft.com/en-us/dotnet/standard/net-standard) documentation may prove helpful when working out if Ocelot would be suitable for you.
|
||||||
|
|
||||||
Install Ocelot and it's dependencies using NuGet.
|
Install Ocelot and it's dependencies using NuGet.
|
||||||
|
|
||||||
|
@ -1 +0,0 @@
|
|||||||
image: Visual Studio 2019
|
|
@ -1,2 +0,0 @@
|
|||||||
./build.ps1 -target BuildAndReleaseUnstable
|
|
||||||
exit $LASTEXITCODE
|
|
@ -1,2 +0,0 @@
|
|||||||
./build.ps1 -target RunTests
|
|
||||||
exit $LASTEXITCODE
|
|
293
build.cake
293
build.cake
@ -1,13 +1,15 @@
|
|||||||
#tool "nuget:?package=GitVersion.CommandLine"
|
#tool "nuget:?package=GitVersion.CommandLine&version=5.0.1"
|
||||||
#tool "nuget:?package=GitReleaseNotes"
|
#tool "nuget:?package=GitReleaseNotes"
|
||||||
#addin nuget:?package=Cake.Json
|
#addin nuget:?package=Cake.Json
|
||||||
#addin nuget:?package=Newtonsoft.Json
|
#addin nuget:?package=Newtonsoft.Json
|
||||||
|
#addin nuget:?package=System.Net.Http
|
||||||
#tool "nuget:?package=ReportGenerator"
|
#tool "nuget:?package=ReportGenerator"
|
||||||
#tool "nuget:?package=coveralls.net&version=0.7.0"
|
#tool "nuget:?package=coveralls.net&version=0.7.0"
|
||||||
#addin Cake.Coveralls&version=0.10.1
|
#addin Cake.Coveralls&version=0.10.1
|
||||||
|
|
||||||
// compile
|
// compile
|
||||||
var compileConfig = Argument("configuration", "Release");
|
var compileConfig = Argument("configuration", "Release");
|
||||||
|
|
||||||
var slnFile = "./Ocelot.sln";
|
var slnFile = "./Ocelot.sln";
|
||||||
|
|
||||||
// build artifacts
|
// build artifacts
|
||||||
@ -17,8 +19,8 @@ var artifactsDir = Directory("artifacts");
|
|||||||
var artifactsForUnitTestsDir = artifactsDir + Directory("UnitTests");
|
var artifactsForUnitTestsDir = artifactsDir + Directory("UnitTests");
|
||||||
var unitTestAssemblies = @"./test/Ocelot.UnitTests/Ocelot.UnitTests.csproj";
|
var unitTestAssemblies = @"./test/Ocelot.UnitTests/Ocelot.UnitTests.csproj";
|
||||||
var minCodeCoverage = 80d;
|
var minCodeCoverage = 80d;
|
||||||
var coverallsRepoToken = "coveralls-repo-token-ocelot";
|
var coverallsRepoToken = "OCELOT_COVERALLS_TOKEN";
|
||||||
var coverallsRepo = "https://coveralls.io/github/TomPallister/Ocelot";
|
var coverallsRepo = "https://coveralls.io/github/ThreeMammals/Ocelot";
|
||||||
|
|
||||||
// acceptance testing
|
// acceptance testing
|
||||||
var artifactsForAcceptanceTestsDir = artifactsDir + Directory("AcceptanceTests");
|
var artifactsForAcceptanceTestsDir = artifactsDir + Directory("AcceptanceTests");
|
||||||
@ -37,27 +39,21 @@ var packagesDir = artifactsDir + Directory("Packages");
|
|||||||
var releaseNotesFile = packagesDir + File("releasenotes.md");
|
var releaseNotesFile = packagesDir + File("releasenotes.md");
|
||||||
var artifactsFile = packagesDir + File("artifacts.txt");
|
var artifactsFile = packagesDir + File("artifacts.txt");
|
||||||
|
|
||||||
// unstable releases
|
|
||||||
var nugetFeedUnstableKey = EnvironmentVariable("nuget-apikey-unstable");
|
|
||||||
var nugetFeedUnstableUploadUrl = "https://www.nuget.org/api/v2/package";
|
|
||||||
var nugetFeedUnstableSymbolsUploadUrl = "https://www.nuget.org/api/v2/package";
|
|
||||||
|
|
||||||
// stable releases
|
// stable releases
|
||||||
var tagsUrl = "https://api.github.com/repos/tompallister/ocelot/releases/tags/";
|
var tagsUrl = "https://api.github.com/repos/ThreeMammals/ocelot/releases/tags/";
|
||||||
var nugetFeedStableKey = EnvironmentVariable("nuget-apikey-stable");
|
var nugetFeedStableKey = EnvironmentVariable("OCELOT_NUTGET_API_KEY");
|
||||||
var nugetFeedStableUploadUrl = "https://www.nuget.org/api/v2/package";
|
var nugetFeedStableUploadUrl = "https://www.nuget.org/api/v2/package";
|
||||||
var nugetFeedStableSymbolsUploadUrl = "https://www.nuget.org/api/v2/package";
|
var nugetFeedStableSymbolsUploadUrl = "https://www.nuget.org/api/v2/package";
|
||||||
|
|
||||||
// internal build variables - don't change these.
|
// internal build variables - don't change these.
|
||||||
var releaseTag = "";
|
|
||||||
string committedVersion = "0.0.0-dev";
|
string committedVersion = "0.0.0-dev";
|
||||||
var buildVersion = committedVersion;
|
|
||||||
GitVersion versioning = null;
|
GitVersion versioning = null;
|
||||||
var nugetFeedUnstableBranchFilter = "^(develop)$|^(PullRequest/)";
|
int releaseId = 0;
|
||||||
|
string gitHubUsername = "TomPallister";
|
||||||
|
string gitHubPassword = Environment.GetEnvironmentVariable("OCELOT_GITHUB_API_KEY");
|
||||||
|
|
||||||
var target = Argument("target", "Default");
|
var target = Argument("target", "Default");
|
||||||
|
|
||||||
|
|
||||||
Information("target is " + target);
|
Information("target is " + target);
|
||||||
Information("Build configuration is " + compileConfig);
|
Information("Build configuration is " + compileConfig);
|
||||||
|
|
||||||
@ -65,12 +61,31 @@ Task("Default")
|
|||||||
.IsDependentOn("Build");
|
.IsDependentOn("Build");
|
||||||
|
|
||||||
Task("Build")
|
Task("Build")
|
||||||
.IsDependentOn("RunTests")
|
.IsDependentOn("RunTests");
|
||||||
.IsDependentOn("CreatePackages");
|
|
||||||
|
|
||||||
Task("BuildAndReleaseUnstable")
|
Task("RunTests")
|
||||||
|
.IsDependentOn("RunUnitTests")
|
||||||
|
.IsDependentOn("RunAcceptanceTests")
|
||||||
|
.IsDependentOn("RunIntegrationTests");
|
||||||
|
|
||||||
|
Task("Release")
|
||||||
.IsDependentOn("Build")
|
.IsDependentOn("Build")
|
||||||
.IsDependentOn("ReleasePackagesToUnstableFeed");
|
.IsDependentOn("CreateArtifacts")
|
||||||
|
.IsDependentOn("PublishGitHubRelease")
|
||||||
|
.IsDependentOn("PublishToNuget");
|
||||||
|
|
||||||
|
Task("Compile")
|
||||||
|
.IsDependentOn("Clean")
|
||||||
|
.IsDependentOn("Version")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
var settings = new DotNetCoreBuildSettings
|
||||||
|
{
|
||||||
|
Configuration = compileConfig,
|
||||||
|
};
|
||||||
|
|
||||||
|
DotNetCoreBuild(slnFile, settings);
|
||||||
|
});
|
||||||
|
|
||||||
Task("Clean")
|
Task("Clean")
|
||||||
.Does(() =>
|
.Does(() =>
|
||||||
@ -89,11 +104,10 @@ Task("Version")
|
|||||||
var nugetVersion = versioning.NuGetVersion;
|
var nugetVersion = versioning.NuGetVersion;
|
||||||
Information("SemVer version number: " + nugetVersion);
|
Information("SemVer version number: " + nugetVersion);
|
||||||
|
|
||||||
if (AppVeyor.IsRunningOnAppVeyor)
|
if (IsRunningOnCircleCI())
|
||||||
{
|
{
|
||||||
Information("Persisting version number...");
|
Information("Persisting version number...");
|
||||||
PersistVersion(committedVersion, nugetVersion);
|
PersistVersion(committedVersion, nugetVersion);
|
||||||
buildVersion = nugetVersion;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -101,19 +115,6 @@ Task("Version")
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Task("Compile")
|
|
||||||
.IsDependentOn("Clean")
|
|
||||||
.IsDependentOn("Version")
|
|
||||||
.Does(() =>
|
|
||||||
{
|
|
||||||
var settings = new DotNetCoreBuildSettings
|
|
||||||
{
|
|
||||||
Configuration = compileConfig,
|
|
||||||
};
|
|
||||||
|
|
||||||
DotNetCoreBuild(slnFile, settings);
|
|
||||||
});
|
|
||||||
|
|
||||||
Task("RunUnitTests")
|
Task("RunUnitTests")
|
||||||
.IsDependentOn("Compile")
|
.IsDependentOn("Compile")
|
||||||
.Does(() =>
|
.Does(() =>
|
||||||
@ -123,18 +124,21 @@ Task("RunUnitTests")
|
|||||||
Configuration = compileConfig,
|
Configuration = compileConfig,
|
||||||
ResultsDirectory = artifactsForUnitTestsDir,
|
ResultsDirectory = artifactsForUnitTestsDir,
|
||||||
ArgumentCustomization = args => args
|
ArgumentCustomization = args => args
|
||||||
|
// this create the code coverage report
|
||||||
.Append("--settings test/Ocelot.UnitTests/UnitTests.runsettings")
|
.Append("--settings test/Ocelot.UnitTests/UnitTests.runsettings")
|
||||||
};
|
};
|
||||||
|
|
||||||
EnsureDirectoryExists(artifactsForUnitTestsDir);
|
EnsureDirectoryExists(artifactsForUnitTestsDir);
|
||||||
DotNetCoreTest(unitTestAssemblies, testSettings);
|
DotNetCoreTest(unitTestAssemblies, testSettings);
|
||||||
|
|
||||||
if (IsRunningOnWindows())
|
|
||||||
{
|
|
||||||
var coverageSummaryFile = GetSubDirectories(artifactsForUnitTestsDir).First().CombineWithFilePath(File("coverage.opencover.xml"));
|
var coverageSummaryFile = GetSubDirectories(artifactsForUnitTestsDir).First().CombineWithFilePath(File("coverage.opencover.xml"));
|
||||||
ReportGenerator(coverageSummaryFile, artifactsForUnitTestsDir);
|
Information(coverageSummaryFile);
|
||||||
|
Information(artifactsForUnitTestsDir);
|
||||||
|
// todo bring back report generator to get a friendly report
|
||||||
|
// ReportGenerator(coverageSummaryFile, artifactsForUnitTestsDir);
|
||||||
|
// https://github.com/danielpalme/ReportGenerator
|
||||||
|
|
||||||
if (AppVeyor.IsRunningOnAppVeyor)
|
if (IsRunningOnCircleCI())
|
||||||
{
|
{
|
||||||
var repoToken = EnvironmentVariable(coverallsRepoToken);
|
var repoToken = EnvironmentVariable(coverallsRepoToken);
|
||||||
if (string.IsNullOrEmpty(repoToken))
|
if (string.IsNullOrEmpty(repoToken))
|
||||||
@ -160,34 +164,15 @@ Task("RunUnitTests")
|
|||||||
|
|
||||||
if(double.Parse(sequenceCoverage) < minCodeCoverage)
|
if(double.Parse(sequenceCoverage) < minCodeCoverage)
|
||||||
{
|
{
|
||||||
var whereToCheck = !AppVeyor.IsRunningOnAppVeyor ? coverallsRepo : artifactsForUnitTestsDir;
|
var whereToCheck = !IsRunningOnCircleCI() ? coverallsRepo : artifactsForUnitTestsDir;
|
||||||
throw new Exception(string.Format("Code coverage fell below the threshold of {0}%. You can find the code coverage report at {1}", minCodeCoverage, whereToCheck));
|
throw new Exception(string.Format("Code coverage fell below the threshold of {0}%. You can find the code coverage report at {1}", minCodeCoverage, whereToCheck));
|
||||||
};
|
};
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Task("RunAcceptanceTests")
|
Task("RunAcceptanceTests")
|
||||||
.IsDependentOn("Compile")
|
.IsDependentOn("Compile")
|
||||||
.Does(() =>
|
.Does(() =>
|
||||||
{
|
{
|
||||||
if(TravisCI.IsRunningOnTravisCI)
|
|
||||||
{
|
|
||||||
Information(
|
|
||||||
@"Job:
|
|
||||||
JobId: {0}
|
|
||||||
JobNumber: {1}
|
|
||||||
OSName: {2}",
|
|
||||||
BuildSystem.TravisCI.Environment.Job.JobId,
|
|
||||||
BuildSystem.TravisCI.Environment.Job.JobNumber,
|
|
||||||
BuildSystem.TravisCI.Environment.Job.OSName
|
|
||||||
);
|
|
||||||
|
|
||||||
if(TravisCI.Environment.Job.OSName.ToLower() == "osx")
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var settings = new DotNetCoreTestSettings
|
var settings = new DotNetCoreTestSettings
|
||||||
{
|
{
|
||||||
Configuration = compileConfig,
|
Configuration = compileConfig,
|
||||||
@ -204,24 +189,6 @@ Task("RunIntegrationTests")
|
|||||||
.IsDependentOn("Compile")
|
.IsDependentOn("Compile")
|
||||||
.Does(() =>
|
.Does(() =>
|
||||||
{
|
{
|
||||||
if(TravisCI.IsRunningOnTravisCI)
|
|
||||||
{
|
|
||||||
Information(
|
|
||||||
@"Job:
|
|
||||||
JobId: {0}
|
|
||||||
JobNumber: {1}
|
|
||||||
OSName: {2}",
|
|
||||||
BuildSystem.TravisCI.Environment.Job.JobId,
|
|
||||||
BuildSystem.TravisCI.Environment.Job.JobNumber,
|
|
||||||
BuildSystem.TravisCI.Environment.Job.OSName
|
|
||||||
);
|
|
||||||
|
|
||||||
if(TravisCI.Environment.Job.OSName.ToLower() == "osx")
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var settings = new DotNetCoreTestSettings
|
var settings = new DotNetCoreTestSettings
|
||||||
{
|
{
|
||||||
Configuration = compileConfig,
|
Configuration = compileConfig,
|
||||||
@ -234,12 +201,7 @@ Task("RunIntegrationTests")
|
|||||||
DotNetCoreTest(integrationTestAssemblies, settings);
|
DotNetCoreTest(integrationTestAssemblies, settings);
|
||||||
});
|
});
|
||||||
|
|
||||||
Task("RunTests")
|
Task("CreateArtifacts")
|
||||||
.IsDependentOn("RunUnitTests")
|
|
||||||
.IsDependentOn("RunAcceptanceTests")
|
|
||||||
.IsDependentOn("RunIntegrationTests");
|
|
||||||
|
|
||||||
Task("CreatePackages")
|
|
||||||
.IsDependentOn("Compile")
|
.IsDependentOn("Compile")
|
||||||
.Does(() =>
|
.Does(() =>
|
||||||
{
|
{
|
||||||
@ -247,6 +209,7 @@ Task("CreatePackages")
|
|||||||
|
|
||||||
CopyFiles("./src/**/Release/Ocelot.*.nupkg", packagesDir);
|
CopyFiles("./src/**/Release/Ocelot.*.nupkg", packagesDir);
|
||||||
|
|
||||||
|
// todo fix this for docker build
|
||||||
//GenerateReleaseNotes(releaseNotesFile);
|
//GenerateReleaseNotes(releaseNotesFile);
|
||||||
|
|
||||||
var projectFiles = GetFiles("./src/**/Release/Ocelot.*.nupkg");
|
var projectFiles = GetFiles("./src/**/Release/Ocelot.*.nupkg");
|
||||||
@ -255,6 +218,7 @@ Task("CreatePackages")
|
|||||||
{
|
{
|
||||||
System.IO.File.AppendAllLines(artifactsFile, new[]{
|
System.IO.File.AppendAllLines(artifactsFile, new[]{
|
||||||
projectFile.GetFilename().FullPath,
|
projectFile.GetFilename().FullPath,
|
||||||
|
// todo fix this for docker build
|
||||||
//"releaseNotes:releasenotes.md"
|
//"releaseNotes:releasenotes.md"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -269,25 +233,24 @@ Task("CreatePackages")
|
|||||||
|
|
||||||
Information("Created package " + codePackage);
|
Information("Created package " + codePackage);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (AppVeyor.IsRunningOnAppVeyor)
|
Task("PublishGitHubRelease")
|
||||||
|
.IsDependentOn("CreateArtifacts")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
if (IsRunningOnCircleCI())
|
||||||
{
|
{
|
||||||
var path = packagesDir.ToString() + @"/**/*";
|
var path = packagesDir.ToString() + @"/**/*";
|
||||||
|
|
||||||
|
CreateGitHubRelease();
|
||||||
|
|
||||||
foreach (var file in GetFiles(path))
|
foreach (var file in GetFiles(path))
|
||||||
{
|
{
|
||||||
AppVeyor.UploadArtifact(file.FullPath);
|
UploadFileToGitHubRelease(file);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Task("ReleasePackagesToUnstableFeed")
|
CompleteGitHubRelease();
|
||||||
.IsDependentOn("CreatePackages")
|
|
||||||
.Does(() =>
|
|
||||||
{
|
|
||||||
if (ShouldPublishToUnstableFeed(nugetFeedUnstableBranchFilter, versioning.BranchName))
|
|
||||||
{
|
|
||||||
PublishPackages(packagesDir, artifactsFile, nugetFeedUnstableKey, nugetFeedUnstableUploadUrl, nugetFeedUnstableSymbolsUploadUrl);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -296,74 +259,34 @@ Task("EnsureStableReleaseRequirements")
|
|||||||
{
|
{
|
||||||
Information("Check if stable release...");
|
Information("Check if stable release...");
|
||||||
|
|
||||||
if (!AppVeyor.IsRunningOnAppVeyor)
|
if (!IsRunningOnCircleCI())
|
||||||
{
|
{
|
||||||
throw new Exception("Stable release should happen via appveyor");
|
throw new Exception("Stable release should happen via circleci");
|
||||||
}
|
|
||||||
|
|
||||||
Information("Running on AppVeyor...");
|
|
||||||
|
|
||||||
Information("IsTag = " + AppVeyor.Environment.Repository.Tag.IsTag);
|
|
||||||
|
|
||||||
Information("Name = " + AppVeyor.Environment.Repository.Tag.Name);
|
|
||||||
|
|
||||||
var isTag =
|
|
||||||
AppVeyor.Environment.Repository.Tag.IsTag &&
|
|
||||||
!string.IsNullOrWhiteSpace(AppVeyor.Environment.Repository.Tag.Name);
|
|
||||||
|
|
||||||
if (!isTag)
|
|
||||||
{
|
|
||||||
throw new Exception("Stable release should happen from a published GitHub release");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Information("Release is stable...");
|
Information("Release is stable...");
|
||||||
});
|
});
|
||||||
|
|
||||||
Task("UpdateVersionInfo")
|
|
||||||
.IsDependentOn("EnsureStableReleaseRequirements")
|
|
||||||
.Does(() =>
|
|
||||||
{
|
|
||||||
releaseTag = AppVeyor.Environment.Repository.Tag.Name;
|
|
||||||
AppVeyor.UpdateBuildVersion(releaseTag);
|
|
||||||
});
|
|
||||||
|
|
||||||
Task("DownloadGitHubReleaseArtifacts")
|
Task("DownloadGitHubReleaseArtifacts")
|
||||||
.IsDependentOn("UpdateVersionInfo")
|
|
||||||
.Does(() =>
|
.Does(() =>
|
||||||
{
|
{
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Information("DownloadGitHubReleaseArtifacts");
|
|
||||||
|
|
||||||
EnsureDirectoryExists(packagesDir);
|
EnsureDirectoryExists(packagesDir);
|
||||||
|
|
||||||
Information("Directory exists...");
|
var releaseUrl = tagsUrl + versioning.NuGetVersion;
|
||||||
|
|
||||||
var releaseUrl = tagsUrl + releaseTag;
|
|
||||||
|
|
||||||
Information("Release url " + releaseUrl);
|
|
||||||
|
|
||||||
var assets_url = Newtonsoft.Json.Linq.JObject.Parse(GetResource(releaseUrl))
|
var assets_url = Newtonsoft.Json.Linq.JObject.Parse(GetResource(releaseUrl))
|
||||||
.Value<string>("assets_url");
|
.Value<string>("assets_url");
|
||||||
|
|
||||||
Information("Assets url " + assets_url);
|
|
||||||
|
|
||||||
var assets = GetResource(assets_url);
|
var assets = GetResource(assets_url);
|
||||||
|
|
||||||
Information("Assets " + assets_url);
|
|
||||||
|
|
||||||
foreach(var asset in Newtonsoft.Json.JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JArray>(assets))
|
foreach(var asset in Newtonsoft.Json.JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JArray>(assets))
|
||||||
{
|
{
|
||||||
Information("In the loop..");
|
|
||||||
|
|
||||||
var file = packagesDir + File(asset.Value<string>("name"));
|
var file = packagesDir + File(asset.Value<string>("name"));
|
||||||
|
|
||||||
Information("Downloading " + file);
|
|
||||||
|
|
||||||
DownloadFile(asset.Value<string>("browser_download_url"), file);
|
DownloadFile(asset.Value<string>("browser_download_url"), file);
|
||||||
}
|
}
|
||||||
|
|
||||||
Information("Out of the loop...");
|
|
||||||
}
|
}
|
||||||
catch(Exception exception)
|
catch(Exception exception)
|
||||||
{
|
{
|
||||||
@ -372,16 +295,16 @@ Task("DownloadGitHubReleaseArtifacts")
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Task("ReleasePackagesToStableFeed")
|
Task("PublishToNuget")
|
||||||
.IsDependentOn("DownloadGitHubReleaseArtifacts")
|
.IsDependentOn("DownloadGitHubReleaseArtifacts")
|
||||||
.Does(() =>
|
.Does(() =>
|
||||||
|
{
|
||||||
|
if (IsRunningOnCircleCI())
|
||||||
{
|
{
|
||||||
PublishPackages(packagesDir, artifactsFile, nugetFeedStableKey, nugetFeedStableUploadUrl, nugetFeedStableSymbolsUploadUrl);
|
PublishPackages(packagesDir, artifactsFile, nugetFeedStableKey, nugetFeedStableUploadUrl, nugetFeedStableSymbolsUploadUrl);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Task("Release")
|
|
||||||
.IsDependentOn("ReleasePackagesToStableFeed");
|
|
||||||
|
|
||||||
RunTarget(target);
|
RunTarget(target);
|
||||||
|
|
||||||
/// Gets nuique nuget version for this commit
|
/// Gets nuique nuget version for this commit
|
||||||
@ -444,6 +367,7 @@ private void GenerateReleaseNotes(ConvertableFilePath file)
|
|||||||
/// Publishes code and symbols packages to nuget feed, based on contents of artifacts file
|
/// Publishes code and symbols packages to nuget feed, based on contents of artifacts file
|
||||||
private void PublishPackages(ConvertableDirectoryPath packagesDir, ConvertableFilePath artifactsFile, string feedApiKey, string codeFeedUrl, string symbolFeedUrl)
|
private void PublishPackages(ConvertableDirectoryPath packagesDir, ConvertableFilePath artifactsFile, string feedApiKey, string codeFeedUrl, string symbolFeedUrl)
|
||||||
{
|
{
|
||||||
|
Information("PublishPackages");
|
||||||
var artifacts = System.IO.File
|
var artifacts = System.IO.File
|
||||||
.ReadAllLines(artifactsFile)
|
.ReadAllLines(artifactsFile)
|
||||||
.Distinct();
|
.Distinct();
|
||||||
@ -465,6 +389,81 @@ private void PublishPackages(ConvertableDirectoryPath packagesDir, ConvertableFi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CreateGitHubRelease()
|
||||||
|
{
|
||||||
|
var json = $"{{ \"tag_name\": \"{versioning.NuGetVersion}\", \"target_commitish\": \"master\", \"name\": \"{versioning.NuGetVersion}\", \"body\": \"todo: notes coming\", \"draft\": true, \"prerelease\": true }}";
|
||||||
|
var content = new System.Net.Http.StringContent(json, System.Text.Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
using(var client = new System.Net.Http.HttpClient())
|
||||||
|
{
|
||||||
|
client.DefaultRequestHeaders.Authorization =
|
||||||
|
new System.Net.Http.Headers.AuthenticationHeaderValue(
|
||||||
|
"Basic", Convert.ToBase64String(
|
||||||
|
System.Text.ASCIIEncoding.ASCII.GetBytes(
|
||||||
|
$"{gitHubUsername}:{gitHubPassword}")));
|
||||||
|
|
||||||
|
client.DefaultRequestHeaders.Add("User-Agent", "Ocelot Release");
|
||||||
|
|
||||||
|
var result = client.PostAsync("https://api.github.com/repos/ThreeMammals/Ocelot/releases", content).Result;
|
||||||
|
if(result.StatusCode != System.Net.HttpStatusCode.Created)
|
||||||
|
{
|
||||||
|
throw new Exception("CreateGitHubRelease result.StatusCode = " + result.StatusCode);
|
||||||
|
}
|
||||||
|
var returnValue = result.Content.ReadAsStringAsync().Result;
|
||||||
|
dynamic test = Newtonsoft.Json.JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(returnValue);
|
||||||
|
releaseId = test.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UploadFileToGitHubRelease(FilePath file)
|
||||||
|
{
|
||||||
|
var data = System.IO.File.ReadAllBytes(file.FullPath);
|
||||||
|
var content = new System.Net.Http.ByteArrayContent(data);
|
||||||
|
content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
|
||||||
|
|
||||||
|
using(var client = new System.Net.Http.HttpClient())
|
||||||
|
{
|
||||||
|
client.DefaultRequestHeaders.Authorization =
|
||||||
|
new System.Net.Http.Headers.AuthenticationHeaderValue(
|
||||||
|
"Basic", Convert.ToBase64String(
|
||||||
|
System.Text.ASCIIEncoding.ASCII.GetBytes(
|
||||||
|
$"{gitHubUsername}:{gitHubPassword}")));
|
||||||
|
|
||||||
|
client.DefaultRequestHeaders.Add("User-Agent", "Ocelot Release");
|
||||||
|
|
||||||
|
var result = client.PostAsync($"https://uploads.github.com/repos/ThreeMammals/Ocelot/releases/{releaseId}/assets?name={file.GetFilename()}", content).Result;
|
||||||
|
if(result.StatusCode != System.Net.HttpStatusCode.Created)
|
||||||
|
{
|
||||||
|
throw new Exception("UploadFileToGitHubRelease result.StatusCode = " + result.StatusCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CompleteGitHubRelease()
|
||||||
|
{
|
||||||
|
var json = $"{{ \"tag_name\": \"{versioning.NuGetVersion}\", \"target_commitish\": \"master\", \"name\": \"{versioning.NuGetVersion}\", \"body\": \"todo: notes coming\", \"draft\": false, \"prerelease\": false }}";
|
||||||
|
var request = new System.Net.Http.HttpRequestMessage(new System.Net.Http.HttpMethod("Patch"), $"https://api.github.com/repos/ThreeMammals/Ocelot/releases/{releaseId}");
|
||||||
|
request.Content = new System.Net.Http.StringContent(json, System.Text.Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
using(var client = new System.Net.Http.HttpClient())
|
||||||
|
{
|
||||||
|
client.DefaultRequestHeaders.Authorization =
|
||||||
|
new System.Net.Http.Headers.AuthenticationHeaderValue(
|
||||||
|
"Basic", Convert.ToBase64String(
|
||||||
|
System.Text.ASCIIEncoding.ASCII.GetBytes(
|
||||||
|
$"{gitHubUsername}:{gitHubPassword}")));
|
||||||
|
|
||||||
|
client.DefaultRequestHeaders.Add("User-Agent", "Ocelot Release");
|
||||||
|
|
||||||
|
var result = client.SendAsync(request).Result;
|
||||||
|
if(result.StatusCode != System.Net.HttpStatusCode.OK)
|
||||||
|
{
|
||||||
|
throw new Exception("CompleteGitHubRelease result.StatusCode = " + result.StatusCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// gets the resource from the specified url
|
/// gets the resource from the specified url
|
||||||
private string GetResource(string url)
|
private string GetResource(string url)
|
||||||
{
|
{
|
||||||
@ -495,17 +494,7 @@ private string GetResource(string url)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ShouldPublishToUnstableFeed(string filter, string branchName)
|
private bool IsRunningOnCircleCI()
|
||||||
{
|
{
|
||||||
var regex = new System.Text.RegularExpressions.Regex(filter);
|
return !string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("CIRCLECI"));
|
||||||
var publish = regex.IsMatch(branchName);
|
|
||||||
if (publish)
|
|
||||||
{
|
|
||||||
Information("Branch " + branchName + " will be published to the unstable feed");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Information("Branch " + branchName + " will not be published to the unstable feed");
|
|
||||||
}
|
|
||||||
return publish;
|
|
||||||
}
|
}
|
44
build.ps1
44
build.ps1
@ -59,7 +59,10 @@ try {
|
|||||||
# Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't
|
# Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't
|
||||||
# exist in .NET 4.0, even though they are addressable if .NET 4.5+ is
|
# exist in .NET 4.0, even though they are addressable if .NET 4.5+ is
|
||||||
# installed (.NET 4.5 is an in-place upgrade).
|
# installed (.NET 4.5 is an in-place upgrade).
|
||||||
|
# PowerShell Core already has support for TLS 1.2 so we can skip this if running in that.
|
||||||
|
if (-not $IsCoreCLR) {
|
||||||
[System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
|
[System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3'
|
Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3'
|
||||||
}
|
}
|
||||||
@ -118,7 +121,7 @@ $MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"
|
|||||||
# Make sure tools folder exists
|
# Make sure tools folder exists
|
||||||
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
|
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
|
||||||
Write-Verbose -Message "Creating tools directory..."
|
Write-Verbose -Message "Creating tools directory..."
|
||||||
New-Item -Path $TOOLS_DIR -Type directory | out-null
|
New-Item -Path $TOOLS_DIR -Type Directory | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Make sure that packages.config exist.
|
# Make sure that packages.config exist.
|
||||||
@ -155,7 +158,12 @@ if (!(Test-Path $NUGET_EXE)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Save nuget.exe path to environment to be available to child processed
|
# Save nuget.exe path to environment to be available to child processed
|
||||||
$ENV:NUGET_EXE = $NUGET_EXE
|
$env:NUGET_EXE = $NUGET_EXE
|
||||||
|
$env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
|
||||||
|
"mono `"$NUGET_EXE`""
|
||||||
|
} else {
|
||||||
|
"`"$NUGET_EXE`""
|
||||||
|
}
|
||||||
|
|
||||||
# Restore tools from NuGet?
|
# Restore tools from NuGet?
|
||||||
if(-Not $SkipToolPackageRestore.IsPresent) {
|
if(-Not $SkipToolPackageRestore.IsPresent) {
|
||||||
@ -163,16 +171,17 @@ if(-Not $SkipToolPackageRestore.IsPresent) {
|
|||||||
Set-Location $TOOLS_DIR
|
Set-Location $TOOLS_DIR
|
||||||
|
|
||||||
# Check for changes in packages.config and remove installed tools if true.
|
# Check for changes in packages.config and remove installed tools if true.
|
||||||
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
|
[string] $md5Hash = MD5HashFile $PACKAGES_CONFIG
|
||||||
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
|
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
|
||||||
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
|
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
|
||||||
Write-Verbose -Message "Missing or changed package.config hash..."
|
Write-Verbose -Message "Missing or changed package.config hash..."
|
||||||
Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery |
|
Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery |
|
||||||
Remove-Item -Recurse
|
Remove-Item -Recurse -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Verbose -Message "Restoring tools from NuGet..."
|
Write-Verbose -Message "Restoring tools from NuGet..."
|
||||||
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
|
|
||||||
|
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Throw "An error occurred while restoring NuGet tools."
|
Throw "An error occurred while restoring NuGet tools."
|
||||||
@ -181,7 +190,7 @@ if(-Not $SkipToolPackageRestore.IsPresent) {
|
|||||||
{
|
{
|
||||||
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
|
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
|
||||||
}
|
}
|
||||||
Write-Verbose -Message ($NuGetOutput | out-string)
|
Write-Verbose -Message ($NuGetOutput | Out-String)
|
||||||
|
|
||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
@ -192,13 +201,13 @@ if (Test-Path $ADDINS_PACKAGES_CONFIG) {
|
|||||||
Set-Location $ADDINS_DIR
|
Set-Location $ADDINS_DIR
|
||||||
|
|
||||||
Write-Verbose -Message "Restoring addins from NuGet..."
|
Write-Verbose -Message "Restoring addins from NuGet..."
|
||||||
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
|
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Throw "An error occurred while restoring NuGet addins."
|
Throw "An error occurred while restoring NuGet addins."
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Verbose -Message ($NuGetOutput | out-string)
|
Write-Verbose -Message ($NuGetOutput | Out-String)
|
||||||
|
|
||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
@ -209,13 +218,13 @@ if (Test-Path $MODULES_PACKAGES_CONFIG) {
|
|||||||
Set-Location $MODULES_DIR
|
Set-Location $MODULES_DIR
|
||||||
|
|
||||||
Write-Verbose -Message "Restoring modules from NuGet..."
|
Write-Verbose -Message "Restoring modules from NuGet..."
|
||||||
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
|
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
|
||||||
|
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Throw "An error occurred while restoring NuGet modules."
|
Throw "An error occurred while restoring NuGet modules."
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Verbose -Message ($NuGetOutput | out-string)
|
Write-Verbose -Message ($NuGetOutput | Out-String)
|
||||||
|
|
||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
@ -225,11 +234,16 @@ if (!(Test-Path $CAKE_EXE)) {
|
|||||||
Throw "Could not find Cake.exe at $CAKE_EXE"
|
Throw "Could not find Cake.exe at $CAKE_EXE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
|
||||||
|
"mono `"$CAKE_EXE`""
|
||||||
|
} else {
|
||||||
|
"`"$CAKE_EXE`""
|
||||||
|
}
|
||||||
|
|
||||||
|
# Build an array (not a string) of Cake arguments to be joined later
|
||||||
# Build Cake arguments
|
$cakeArguments = @()
|
||||||
$cakeArguments = @("$Script");
|
if ($Script) { $cakeArguments += "`"$Script`"" }
|
||||||
if ($Target) { $cakeArguments += "-target=$Target" }
|
if ($Target) { $cakeArguments += "-target=`"$Target`"" }
|
||||||
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
|
if ($Configuration) { $cakeArguments += "-configuration=$Configuration" }
|
||||||
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
|
if ($Verbosity) { $cakeArguments += "-verbosity=$Verbosity" }
|
||||||
if ($ShowDescription) { $cakeArguments += "-showdescription" }
|
if ($ShowDescription) { $cakeArguments += "-showdescription" }
|
||||||
@ -238,5 +252,5 @@ $cakeArguments += $ScriptArgs
|
|||||||
|
|
||||||
# Start Cake
|
# Start Cake
|
||||||
Write-Host "Running build script..."
|
Write-Host "Running build script..."
|
||||||
&$CAKE_EXE $cakeArguments
|
Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ")"
|
||||||
exit $LASTEXITCODE
|
exit $LASTEXITCODE
|
||||||
|
9
docker/Dockerfile.base
Normal file
9
docker/Dockerfile.base
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# this is the dockerfile that create the ocelot build container
|
||||||
|
# build with the docker-build.sh file in this folder
|
||||||
|
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-bionic AS build
|
||||||
|
|
||||||
|
RUN apt install gnupg ca-certificates
|
||||||
|
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
|
||||||
|
RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | tee /etc/apt/sources.list.d/mono-official-stable.list
|
||||||
|
RUN apt update
|
||||||
|
RUN apt-get -y install mono-devel
|
15
docker/Dockerfile.build
Normal file
15
docker/Dockerfile.build
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# call from ocelot repo root with
|
||||||
|
# docker build --build-arg OCELOT_COVERALLS_TOKEN=$OCELOT_COVERALLS_TOKEN -f ./docker/Dockerfile.build .
|
||||||
|
FROM mijitt0m/ocelot-build:0.0.1
|
||||||
|
|
||||||
|
ARG OCELOT_COVERALLS_TOKEN
|
||||||
|
|
||||||
|
ENV OCELOT_COVERALLS_TOKEN=$OCELOT_COVERALLS_TOKEN
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
COPY ./. .
|
||||||
|
|
||||||
|
RUN chmod u+x build.sh
|
||||||
|
|
||||||
|
RUN make build
|
20
docker/Dockerfile.release
Normal file
20
docker/Dockerfile.release
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# call from ocelot repo root with
|
||||||
|
# docker build --build-arg OCELOT_COVERALLS_TOKEN=$OCELOT_COVERALLS_TOKEN --build-arg OCELOT_GITHUB_API_KEY=$OCELOT_GITHUB_API_KEY --build-arg OCELOT_COVERALLS_TOKEN=$OCELOT_COVERALLS_TOKEN -f ./docker/Dockerfile.release .
|
||||||
|
|
||||||
|
FROM mijitt0m/ocelot-build:0.0.1
|
||||||
|
|
||||||
|
ARG OCELOT_COVERALLS_TOKEN
|
||||||
|
ARG OCELOT_NUTGET_API_KEY
|
||||||
|
ARG OCELOT_GITHUB_API_KEY
|
||||||
|
|
||||||
|
ENV OCELOT_COVERALLS_TOKEN=$OCELOT_COVERALLS_TOKEN
|
||||||
|
ENV OCELOT_NUTGET_API_KEY=$OCELOT_NUTGET_API_KEY
|
||||||
|
ENV OCELOT_GITHUB_API_KEY=$OCELOT_GITHUB_API_KEY
|
||||||
|
|
||||||
|
WORKDIR /src
|
||||||
|
|
||||||
|
COPY ./. .
|
||||||
|
|
||||||
|
RUN chmod u+x build.sh
|
||||||
|
|
||||||
|
RUN make release
|
3
docker/README.md
Normal file
3
docker/README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# docker build
|
||||||
|
|
||||||
|
This folder contains the dockerfile and script to create the ocelot build container.
|
6
docker/docker-build.sh
Executable file
6
docker/docker-build.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
# this script build the ocelot docker file
|
||||||
|
docker build -t mijitt0m/ocelot-build -f Dockerfile.base .
|
||||||
|
echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin
|
||||||
|
docker tag mijitt0m/ocelot-build mijitt0m/ocelot-build:0.0.1
|
||||||
|
docker push mijitt0m/ocelot-build:latest
|
||||||
|
docker push mijitt0m/ocelot-build:0.0.1
|
@ -1,12 +1,10 @@
|
|||||||
Building
|
Building
|
||||||
========
|
========
|
||||||
|
|
||||||
* You'll generally want to run the `./build.ps1` script. This will compile, run unit and acceptance tests and build the output packages locally. Output will got to the `./artifacts` directory.
|
* The best way to build Ocelot is using the Dockerfile.build file which can be found in the docker folder in Ocelot root. Use the following command `docker build -f ./docker/Dockerfile.build .`.
|
||||||
|
|
||||||
* You can view the current commit's `SemVer <http://semver.org/>`_ build information by running `./version.ps1`.
|
* You'll can run the `./build.ps1` or `./build.sh` script depending on your OS. This will compile, run unit and acceptance tests and build the output packages locally. Output will got to the `./artifacts` directory.
|
||||||
|
|
||||||
* The other `./*.ps1` scripts perform subsets of the build process, if you don't want to run the full build.
|
* There is a Makefile to make it easier to call the various targers in `build.cake`. The scripts are called with .sh but can be easily changed to ps1 if you are using Windows.
|
||||||
|
|
||||||
* The release process works best with GitFlow branching; this allows us to publish every development commit to an unstable feed with a unique SemVer version, and then choose when to release to a stable feed.
|
* Alternatively you can build the project in VS2019 with the latest .NET Core SDK.
|
||||||
|
|
||||||
* Alternatively you can build the project in VS2017 with the latest .NET Core SDK.
|
|
@ -1,4 +1,4 @@
|
|||||||
Overview
|
Overview
|
||||||
========
|
========
|
||||||
|
|
||||||
This document summarises the build and release process for the project. The build scripts are written using `Cake <http://cakebuild.net/>`_, and are defined in `./build.cake`. The scripts have been designed to be run by either developers locally or by a build server (currently `AppVeyor <https://www.appveyor.com/>`_), with minimal logic defined in the build server itself.
|
This document summarises the build and release process for the project. The build scripts are written using `Cake <http://cakebuild.net/>`_, and are defined in `./build.cake`. The scripts have been designed to be run by either developers locally or by a build server (currently `CircleCi <https://circleci.com//>`_), with minimal logic defined in the build server itself.
|
@ -1,13 +1,16 @@
|
|||||||
Release process
|
Release process
|
||||||
===============
|
===============
|
||||||
|
|
||||||
|
* The release process works best with GitHubFlow branching.
|
||||||
|
* Contributors can do whatever they want on PRs and merges to master will result in packages being released to GitHub and NuGet.
|
||||||
|
|
||||||
Ocelot uses the following process to accept work into the NuGet packages.
|
Ocelot uses the following process to accept work into the NuGet packages.
|
||||||
|
|
||||||
1. User creates an issue or picks up an existing issue in GitHub.
|
1. User creates an issue or picks up an existing issue in GitHub.
|
||||||
|
|
||||||
2. User creates a fork and branches from this (unless a member of core team, they can just create a branch on the main repo) e.g. feat/xxx, fix/xxx etc. It doesn't really matter what the xxx is. It might make sense to use the issue number and maybe a short description. I don't care as long as it has (feat, fix, refactor)/xxx :)
|
2. User creates a fork and branches from this (unless a member of core team, they can just create a branch on the main repo) e.g. feat/xxx, fix/xxx etc. It doesn't really matter what the xxx is. It might make sense to use the issue number and maybe a short description. I don't care as long as it has (feat, fix, refactor)/xxx :)
|
||||||
|
|
||||||
3. When the user is happy with their work they can create a pull request in GitHub with their changes. The user must follow the `SemVer <https://semver.org/>`_ support for this is provided by `GitVersion <https://gitversion.readthedocs.io/en/latest/>`_. So if you need to make breaking changes please make sure you use the correct commit message so GitVersion uses the correct semver tags. Do not manually tag the Ocelot repo this will break things.
|
3. When the user is happy with their work they can create a pull request against master in GitHub with their changes. The user must follow the `SemVer <https://semver.org/>`_ support for this is provided by `GitVersion <https://gitversion.readthedocs.io/en/latest/>`_. So if you need to make breaking changes please make sure you use the correct commit message so GitVersion uses the correct semver tags. Do not manually tag the Ocelot repo this will break things.
|
||||||
|
|
||||||
4. The Ocelot team will review the PR and if all is good merge it, else they will suggest feedback that the user will need to act on. In order to speed up getting a PR the user should think about the following.
|
4. The Ocelot team will review the PR and if all is good merge it, else they will suggest feedback that the user will need to act on. In order to speed up getting a PR the user should think about the following.
|
||||||
- Have I covered all my changes with tests at unit and acceptance level?
|
- Have I covered all my changes with tests at unit and acceptance level?
|
||||||
@ -16,23 +19,17 @@ Ocelot uses the following process to accept work into the NuGet packages.
|
|||||||
In order for a PR to be merged the following must have occured.
|
In order for a PR to be merged the following must have occured.
|
||||||
- All new code is covered by unit tests.
|
- All new code is covered by unit tests.
|
||||||
- All new code has at least 1 acceptance test covering the happy path.
|
- All new code has at least 1 acceptance test covering the happy path.
|
||||||
- Builds for Windows, Mac and Linux must have passed.
|
- Tests must have passed.
|
||||||
- Builds for Windows, Mac and Linux must not have slowed down dramatically.
|
- Build must not have slowed down dramatically.
|
||||||
- The main Ocelot package must not have taken on any non MS dependencies.
|
- The main Ocelot package must not have taken on any non MS dependencies.
|
||||||
|
|
||||||
5. After the PR is merged the GitHub issue must be labelled as merged. The merge will trigger an alpha build on the develop branch with these changes that will get pushed to NuGet. You can import this and test it manually should you wish.
|
5. After the PR is merged to master the release process will begin which builds the code, versions it, pushes artifacts to GitHub and NuGet packages to NuGet.
|
||||||
|
|
||||||
6. When the Ocelot team is ready to create a release they will checkout a new release branch with the version from the latest develop build. So look in AppVeyor for the latest develop semver number and checkout a new branch e.g. git checkout -b release/13.1.0 and push this to the remote. Wait for it to build and then merge this branch back into master.
|
6. The final step is to go back to GitHub and close any issues that are now fixed. You should see something like this in`GitHub <https://github.com/ThreeMammals/Ocelot/releases/tag/13.0.0>`_ and this in `NuGet <https://www.nuget.org/packages/Ocelot/13.0.0>`_.
|
||||||
|
|
||||||
7. Wait for the master build to complete. When it has go to the AppVeyor UI and find the build and click the Deploy link in the top right hand corner. Select release preparation from the environment drop down and click deploy. This will send the release information to GitHub releases.
|
|
||||||
|
|
||||||
8. Go to GitHub releases and find the version you have just released. It will look something like 13.0.0+31.build.1783. Remove +31.build.1783 (or whatever you get) from all the input fields so you are just left with 13.0.0. Untick This is a pre release and click release. This will trigger a build from AppVeyor that downloads the release artifacts from GitHub and publishes them to the stable NuGet feed. All being well you should find your new package on NuGet within 30 minutes. You might also want to manually add the issue numbers of what has been merged so people can see what changed in this release.
|
|
||||||
|
|
||||||
9. The final step is to go back to GitHub and close any issues that were labelled as merged. You should see something like this in`GitHub <https://github.com/ThreeMammals/Ocelot/releases/tag/13.0.0>`_ and this in `NuGet <https://www.nuget.org/packages/Ocelot/13.0.0>`_.
|
|
||||||
|
|
||||||
Notes
|
Notes
|
||||||
-----
|
-----
|
||||||
|
|
||||||
All NuGet package builds are done with AppVeyor `here <https://ci.appveyor.com/project/TomPallister/ocelot-fcfpb>_` and all releases are done from `here <https://ci.appveyor.com/project/TomPallister/ocelot-ayj4w>_`. We also build Ocelot on Travis `here <https://travis-ci.org/ThreeMammals/Ocelot>`_ but this is only to make sure it is building on multiple OS.
|
All NuGet package builds & releases are done with CircleCI `here <https://circleci.com/gh/ThreeMammals>_` and all releases are done from `here <https://ci.appveyor.com/project/TomPallister/ocelot-ayj4w>_`.
|
||||||
|
|
||||||
Only Ocelot core team members can merge PRs and create release branches. Only TomPallister can merge releases into master at the moment. This is to ensure there is a final quality gate in place. Tom is mainly looking for security issues on the final merge.
|
Only TomPallister can merge releases into master at the moment. This is to ensure there is a final quality gate in place. Tom is mainly looking for security issues on the final merge.
|
||||||
|
@ -32,7 +32,7 @@ Finally in order to use caching on a route in your ReRoute configuration add thi
|
|||||||
|
|
||||||
In this example ttl seconds is set to 15 which means the cache will expire after 15 seconds.
|
In this example ttl seconds is set to 15 which means the cache will expire after 15 seconds.
|
||||||
|
|
||||||
If you look at the example `here <https://github.com/ThreeMammals/Ocelot/blob/develop/test/Ocelot.ManualTest/Program.cs>`_ you can see how the cache manager
|
If you look at the example `here <https://github.com/ThreeMammals/Ocelot/blob/master/test/Ocelot.ManualTest/Program.cs>`_ you can see how the cache manager
|
||||||
is setup and then passed into the Ocelot AddCacheManager configuration method. You can use any settings supported by
|
is setup and then passed into the Ocelot AddCacheManager configuration method. You can use any settings supported by
|
||||||
the CacheManager package and just pass them in.
|
the CacheManager package and just pass them in.
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Configuration
|
Configuration
|
||||||
============
|
============
|
||||||
|
|
||||||
An example configuration can be found `here <https://github.com/ThreeMammals/Ocelot/blob/develop/test/Ocelot.ManualTest/ocelot.json>`_.
|
An example configuration can be found `here <https://github.com/ThreeMammals/Ocelot/blob/master/test/Ocelot.ManualTest/ocelot.json>`_.
|
||||||
There are two sections to the configuration. An array of ReRoutes and a GlobalConfiguration.
|
There are two sections to the configuration. An array of ReRoutes and a GlobalConfiguration.
|
||||||
The ReRoutes are the objects that tell Ocelot how to treat an upstream request. The Global
|
The ReRoutes are the objects that tell Ocelot how to treat an upstream request. The Global
|
||||||
configuration is a bit hacky and allows overrides of ReRoute specific settings. It's useful
|
configuration is a bit hacky and allows overrides of ReRoute specific settings. It's useful
|
||||||
@ -62,7 +62,8 @@ Here is an example ReRoute configuration, You don't need to set all of these thi
|
|||||||
"HttpHandlerOptions": {
|
"HttpHandlerOptions": {
|
||||||
"AllowAutoRedirect": true,
|
"AllowAutoRedirect": true,
|
||||||
"UseCookieContainer": true,
|
"UseCookieContainer": true,
|
||||||
"UseTracing": true
|
"UseTracing": true,
|
||||||
|
"MaxConnectionsPerServer": 100
|
||||||
},
|
},
|
||||||
"DangerousAcceptAnyServerCertificateValidator": false
|
"DangerousAcceptAnyServerCertificateValidator": false
|
||||||
}
|
}
|
||||||
@ -222,3 +223,8 @@ If you want to ignore SSL warnings / errors set the following in your ReRoute co
|
|||||||
"DangerousAcceptAnyServerCertificateValidator": true
|
"DangerousAcceptAnyServerCertificateValidator": true
|
||||||
|
|
||||||
I don't recommend doing this, I suggest creating your own certificate and then getting it trusted by your local / remote machine if you can.
|
I don't recommend doing this, I suggest creating your own certificate and then getting it trusted by your local / remote machine if you can.
|
||||||
|
|
||||||
|
MaxConnectionsPerServer
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
This controls how many connections the internal HttpClient will open. This can be set at ReRoute or global level.
|
@ -5,7 +5,7 @@ OK you got me Ocelot doesn't directly support GraphQL but so many people have as
|
|||||||
the `graphql-dotnet <https://github.com/graphql-dotnet/graphql-dotnet>`_ library.
|
the `graphql-dotnet <https://github.com/graphql-dotnet/graphql-dotnet>`_ library.
|
||||||
|
|
||||||
|
|
||||||
Please see the sample project `OcelotGraphQL <https://github.com/ThreeMammals/Ocelot/tree/develop/samples/OcelotGraphQL>`_.
|
Please see the sample project `OcelotGraphQL <https://github.com/ThreeMammals/Ocelot/tree/master/samples/OcelotGraphQL>`_.
|
||||||
Using a combination of the graphql-dotnet project and Ocelot's DelegatingHandler features this is pretty easy to do.
|
Using a combination of the graphql-dotnet project and Ocelot's DelegatingHandler features this is pretty easy to do.
|
||||||
However I do not intend to integrate more closely with GraphQL at the moment. Check out the samples readme and that should give
|
However I do not intend to integrate more closely with GraphQL at the moment. Check out the samples readme and that should give
|
||||||
you enough instruction on how to do this!
|
you enough instruction on how to do this!
|
||||||
|
@ -155,6 +155,8 @@ Eureka. One of the services polls Eureka every 30 seconds (default) and gets the
|
|||||||
When Ocelot asks for a given service it is retrieved from memory so performance is not a big problem. Please note that this code
|
When Ocelot asks for a given service it is retrieved from memory so performance is not a big problem. Please note that this code
|
||||||
is provided by the Pivotal.Discovery.Client NuGet package so big thanks to them for all the hard work.
|
is provided by the Pivotal.Discovery.Client NuGet package so big thanks to them for all the hard work.
|
||||||
|
|
||||||
|
Ocelot will use the scheme (http/https) set in Eureka if these values are not provided in ocelot.json
|
||||||
|
|
||||||
Dynamic Routing
|
Dynamic Routing
|
||||||
^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ Getting Started
|
|||||||
Ocelot is designed to work with .NET Core only and is currently
|
Ocelot is designed to work with .NET Core only and is currently
|
||||||
built to netstandard2.0. `This <https://docs.microsoft.com/en-us/dotnet/articles/standard/library>`_ documentation may prove helpful when working out if Ocelot would be suitable for you.
|
built to netstandard2.0. `This <https://docs.microsoft.com/en-us/dotnet/articles/standard/library>`_ documentation may prove helpful when working out if Ocelot would be suitable for you.
|
||||||
|
|
||||||
.NET Core 2.1
|
.NET Core 3.1
|
||||||
^^^^^^^^^^^^^
|
^^^^^^^^^^^^^
|
||||||
|
|
||||||
**Install NuGet package**
|
**Install NuGet package**
|
||||||
@ -29,6 +29,30 @@ The following is a very basic ocelot.json. It won't do anything but should get O
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
If you want some example that actually does something use the following:
|
||||||
|
|
||||||
|
.. code-block:: json
|
||||||
|
|
||||||
|
{
|
||||||
|
"ReRoutes": [
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/todos/{id}",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "jsonplaceholder.typicode.com",
|
||||||
|
"Port": 443
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/todos/{id}",
|
||||||
|
"UpstreamHttpMethod": [ "Get" ]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"GlobalConfiguration": {
|
||||||
|
"BaseUrl": "https://localhost:5000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
The most important thing to note here is BaseUrl. Ocelot needs to know the URL it is running under
|
The most important thing to note here is BaseUrl. Ocelot needs to know the URL it is running under
|
||||||
in order to do Header find & replace and for certain administration configurations. When setting this URL it should be the external URL that clients will see Ocelot running on e.g. If you are running containers Ocelot might run on the url http://123.12.1.1:6543 but has something like nginx in front of it responding on https://api.mybusiness.com. In this case the Ocelot base url should be https://api.mybusiness.com.
|
in order to do Header find & replace and for certain administration configurations. When setting this URL it should be the external URL that clients will see Ocelot running on e.g. If you are running containers Ocelot might run on the url http://123.12.1.1:6543 but has something like nginx in front of it responding on https://api.mybusiness.com. In this case the Ocelot base url should be https://api.mybusiness.com.
|
||||||
|
|
||||||
@ -42,9 +66,15 @@ AddOcelot() (adds ocelot services), UseOcelot().Wait() (sets up all the Ocelot m
|
|||||||
|
|
||||||
.. code-block:: csharp
|
.. code-block:: csharp
|
||||||
|
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
using Ocelot.DependencyInjection;
|
using Ocelot.DependencyInjection;
|
||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
|
|
||||||
|
namespace OcelotBasic
|
||||||
|
{
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
@ -77,6 +107,8 @@ AddOcelot() (adds ocelot services), UseOcelot().Wait() (sets up all the Ocelot m
|
|||||||
.Run();
|
.Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
**Note:** When using ASP.NET Core 2.2 and you want to use In-Process hosting, replace **.UseIISIntegration()** with **.UseIIS()**, otherwise you'll get startup errors.
|
**Note:** When using ASP.NET Core 2.2 and you want to use In-Process hosting, replace **.UseIISIntegration()** with **.UseIIS()**, otherwise you'll get startup errors.
|
||||||
|
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
./build.ps1 -target Release
|
|
||||||
exit $LASTEXITCODE
|
|
@ -1,2 +0,0 @@
|
|||||||
./build -target RunAcceptanceTests
|
|
||||||
exit $LASTEXITCODE
|
|
@ -1,3 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
./build.sh --target RunAcceptanceTests
|
|
@ -1,2 +0,0 @@
|
|||||||
./build.ps1 -target RunBenchmarkTests
|
|
||||||
exit $LASTEXITCODE
|
|
@ -1,2 +0,0 @@
|
|||||||
./build.ps1 -target RunUnitTests
|
|
||||||
exit $LASTEXITCODE
|
|
@ -1,3 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
./build.sh --target RunUnitTests
|
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="wwwroot\"/>
|
<Folder Include="wwwroot\"/>
|
||||||
|
0
samples/Docker/README.md
Normal file
0
samples/Docker/README.md
Normal file
16
samples/OcelotBasic/OcelotBasic.csproj
Normal file
16
samples/OcelotBasic/OcelotBasic.csproj
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="ocelot" Version="13.8.4" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Properties\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
</Project>
|
42
samples/OcelotBasic/Program.cs
Normal file
42
samples/OcelotBasic/Program.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
using System.IO;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Ocelot.DependencyInjection;
|
||||||
|
using Ocelot.Middleware;
|
||||||
|
|
||||||
|
namespace OcelotBasic
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
new WebHostBuilder()
|
||||||
|
.UseKestrel()
|
||||||
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
|
.ConfigureAppConfiguration((hostingContext, config) =>
|
||||||
|
{
|
||||||
|
config
|
||||||
|
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
|
||||||
|
.AddJsonFile("appsettings.json", true, true)
|
||||||
|
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
|
||||||
|
.AddJsonFile("ocelot.json")
|
||||||
|
.AddEnvironmentVariables();
|
||||||
|
})
|
||||||
|
.ConfigureServices(s => {
|
||||||
|
s.AddOcelot();
|
||||||
|
})
|
||||||
|
.ConfigureLogging((hostingContext, logging) =>
|
||||||
|
{
|
||||||
|
//add your logging
|
||||||
|
})
|
||||||
|
.UseIISIntegration()
|
||||||
|
.Configure(app =>
|
||||||
|
{
|
||||||
|
app.UseOcelot().Wait();
|
||||||
|
})
|
||||||
|
.Build()
|
||||||
|
.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
27
samples/OcelotBasic/Properties/launchSettings.json
Normal file
27
samples/OcelotBasic/Properties/launchSettings.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:55029/",
|
||||||
|
"sslPort": 44390
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"OcelotBasic": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
},
|
||||||
|
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
9
samples/OcelotBasic/appsettings.Development.json
Normal file
9
samples/OcelotBasic/appsettings.Development.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft": "Warning",
|
||||||
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
10
samples/OcelotBasic/appsettings.json
Normal file
10
samples/OcelotBasic/appsettings.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft": "Warning",
|
||||||
|
"Microsoft.Hosting.Lifetime": "Information"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*"
|
||||||
|
}
|
21
samples/OcelotBasic/ocelot.json
Normal file
21
samples/OcelotBasic/ocelot.json
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"ReRoutes": [
|
||||||
|
{
|
||||||
|
"DownstreamPathTemplate": "/todos/{id}",
|
||||||
|
"DownstreamScheme": "https",
|
||||||
|
"DownstreamHostAndPorts": [
|
||||||
|
{
|
||||||
|
"Host": "jsonplaceholder.typicode.com",
|
||||||
|
"Port": 443
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"UpstreamPathTemplate": "/posts/{id}",
|
||||||
|
"UpstreamHttpMethod": [
|
||||||
|
"Get"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"GlobalConfiguration": {
|
||||||
|
"BaseUrl": "https://localhost:5000"
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -15,7 +15,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.5" />
|
|
||||||
<PackageReference Include="Ocelot" Version="13.5.1" />
|
<PackageReference Include="Ocelot" Version="13.5.1" />
|
||||||
<PackageReference Include="Ocelot.Provider.Eureka" Version="13.5.1" />
|
<PackageReference Include="Ocelot.Provider.Eureka" Version="13.5.1" />
|
||||||
<PackageReference Include="Ocelot.Provider.Polly" Version="13.5.1" />
|
<PackageReference Include="Ocelot.Provider.Polly" Version="13.5.1" />
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -9,7 +9,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.5" />
|
|
||||||
<PackageReference Include="Steeltoe.Discovery.Client" Version="1.1.0" />
|
<PackageReference Include="Steeltoe.Discovery.Client" Version="1.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Update="ocelot.json;appsettings.json">
|
<None Update="ocelot.json;appsettings.json">
|
||||||
@ -11,7 +11,6 @@
|
|||||||
<Folder Include="wwwroot\" />
|
<Folder Include="wwwroot\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9"/>
|
|
||||||
<PackageReference Include="Ocelot" Version="5.5.1" />
|
<PackageReference Include="Ocelot" Version="5.5.1" />
|
||||||
<PackageReference Include="GraphQL" Version="2.0.0-alpha-870" />
|
<PackageReference Include="GraphQL" Version="2.0.0-alpha-870" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
||||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Description>Stateless Web Service for Stateful OcelotApplicationApiGateway App</Description>
|
<Description>Stateless Web Service for Stateful OcelotApplicationApiGateway App</Description>
|
||||||
<Authors> </Authors>
|
<Authors> </Authors>
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<AssemblyName>OcelotApplicationApiGateway</AssemblyName>
|
<AssemblyName>OcelotApplicationApiGateway</AssemblyName>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<PackageId>OcelotApplicationApiGateway</PackageId>
|
<PackageId>OcelotApplicationApiGateway</PackageId>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<Description>Stateless Service Application</Description>
|
<Description>Stateless Service Application</Description>
|
||||||
<Authors> </Authors>
|
<Authors> </Authors>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<AssemblyName>OcelotApplicationService</AssemblyName>
|
<AssemblyName>OcelotApplicationService</AssemblyName>
|
||||||
<PackageId>OcelotApplicationService</PackageId>
|
<PackageId>OcelotApplicationService</PackageId>
|
||||||
<PackageTargetFallback>$(PackageTargetFallback)</PackageTargetFallback>
|
<PackageTargetFallback>$(PackageTargetFallback)</PackageTargetFallback>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||||
<Description>Provides Ocelot extensions to use the administration API and IdentityService dependencies that come with it</Description>
|
<Description>Provides Ocelot extensions to use the administration API and IdentityService dependencies that come with it</Description>
|
||||||
<AssemblyTitle>Ocelot.Administration</AssemblyTitle>
|
<AssemblyTitle>Ocelot.Administration</AssemblyTitle>
|
||||||
@ -34,6 +34,6 @@
|
|||||||
<PackageReference Include="IdentityServer4" Version="3.0.1" />
|
<PackageReference Include="IdentityServer4" Version="3.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||||
<Description>Provides Ocelot extensions to use CacheManager.Net</Description>
|
<Description>Provides Ocelot extensions to use CacheManager.Net</Description>
|
||||||
<AssemblyTitle>Ocelot.Cache.CacheManager</AssemblyTitle>
|
<AssemblyTitle>Ocelot.Cache.CacheManager</AssemblyTitle>
|
||||||
@ -34,6 +34,6 @@
|
|||||||
<PackageReference Include="CacheManager.Microsoft.Extensions.Logging" Version="2.0.0-beta-1629" />
|
<PackageReference Include="CacheManager.Microsoft.Extensions.Logging" Version="2.0.0-beta-1629" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||||
<Description>Provides Ocelot extensions to use Consul</Description>
|
<Description>Provides Ocelot extensions to use Consul</Description>
|
||||||
<AssemblyTitle>Ocelot.Provider.Consul</AssemblyTitle>
|
<AssemblyTitle>Ocelot.Provider.Consul</AssemblyTitle>
|
||||||
@ -33,6 +33,6 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
if (instances != null && instances.Any())
|
if (instances != null && instances.Any())
|
||||||
{
|
{
|
||||||
services.AddRange(instances.Select(i => new Service(i.ServiceId, new ServiceHostAndPort(i.Host, i.Port), "", "", new List<string>())));
|
services.AddRange(instances.Select(i => new Service(i.ServiceId, new ServiceHostAndPort(i.Host, i.Port, i.Uri.Scheme), "", "", new List<string>())));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.FromResult(services);
|
return Task.FromResult(services);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||||
<Description>Provides Ocelot extensions to use Eureka</Description>
|
<Description>Provides Ocelot extensions to use Eureka</Description>
|
||||||
<AssemblyTitle>Ocelot.Provider.Eureka</AssemblyTitle>
|
<AssemblyTitle>Ocelot.Provider.Eureka</AssemblyTitle>
|
||||||
@ -33,6 +33,6 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||||
<Product>Ocelot</Product>
|
<Product>Ocelot</Product>
|
||||||
<Description>Provides Ocelot extensions to use kubernetes</Description>
|
<Description>Provides Ocelot extensions to use kubernetes</Description>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||||
<Description>Provides Ocelot extensions to use Polly.NET</Description>
|
<Description>Provides Ocelot extensions to use Polly.NET</Description>
|
||||||
<AssemblyTitle>Ocelot.Provider.Polly</AssemblyTitle>
|
<AssemblyTitle>Ocelot.Provider.Polly</AssemblyTitle>
|
||||||
@ -33,6 +33,6 @@
|
|||||||
<PackageReference Include="Polly" Version="7.1.1" />
|
<PackageReference Include="Polly" Version="7.1.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||||
<Description>Provides Ocelot extensions to use Rafty</Description>
|
<Description>Provides Ocelot extensions to use Rafty</Description>
|
||||||
<AssemblyTitle>Ocelot.Provider.Rafty</AssemblyTitle>
|
<AssemblyTitle>Ocelot.Provider.Rafty</AssemblyTitle>
|
||||||
@ -35,6 +35,6 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||||
<Description>This package provides methods to integrate Butterfly tracing with Ocelot.</Description>
|
<Description>This package provides methods to integrate Butterfly tracing with Ocelot.</Description>
|
||||||
<AssemblyTitle>Ocelot.Tracing.Butterfly</AssemblyTitle>
|
<AssemblyTitle>Ocelot.Tracing.Butterfly</AssemblyTitle>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
<PackageReference Include="Butterfly.Client.AspNetCore" Version="0.0.8" />
|
<PackageReference Include="Butterfly.Client.AspNetCore" Version="0.0.8" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ocelot.Configuration.Builder
|
namespace Ocelot.Configuration.Builder
|
||||||
{
|
{
|
||||||
@ -7,6 +8,7 @@ namespace Ocelot.Configuration.Builder
|
|||||||
private bool _enableRateLimiting;
|
private bool _enableRateLimiting;
|
||||||
private string _clientIdHeader;
|
private string _clientIdHeader;
|
||||||
private List<string> _clientWhitelist;
|
private List<string> _clientWhitelist;
|
||||||
|
private Func<List<string>> _getClientWhitelist;
|
||||||
private bool _disableRateLimitHeaders;
|
private bool _disableRateLimitHeaders;
|
||||||
private string _quotaExceededMessage;
|
private string _quotaExceededMessage;
|
||||||
private string _rateLimitCounterPrefix;
|
private string _rateLimitCounterPrefix;
|
||||||
@ -19,15 +21,15 @@ namespace Ocelot.Configuration.Builder
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RateLimitOptionsBuilder WithClientIdHeader(string clientIdheader)
|
public RateLimitOptionsBuilder WithClientIdHeader(string clientIdHeader)
|
||||||
{
|
{
|
||||||
_clientIdHeader = clientIdheader;
|
_clientIdHeader = clientIdHeader;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RateLimitOptionsBuilder WithClientWhiteList(List<string> clientWhitelist)
|
public RateLimitOptionsBuilder WithClientWhiteList(Func<List<string>> getClientWhitelist)
|
||||||
{
|
{
|
||||||
_clientWhitelist = clientWhitelist;
|
_getClientWhitelist = getClientWhitelist;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +65,7 @@ namespace Ocelot.Configuration.Builder
|
|||||||
|
|
||||||
public RateLimitOptions Build()
|
public RateLimitOptions Build()
|
||||||
{
|
{
|
||||||
return new RateLimitOptions(_enableRateLimiting, _clientIdHeader, _clientWhitelist,
|
return new RateLimitOptions(_enableRateLimiting, _clientIdHeader, _getClientWhitelist,
|
||||||
_disableRateLimitHeaders, _quotaExceededMessage, _rateLimitCounterPrefix,
|
_disableRateLimitHeaders, _quotaExceededMessage, _rateLimitCounterPrefix,
|
||||||
_rateLimitRule, _httpStatusCode);
|
_rateLimitRule, _httpStatusCode);
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,11 @@
|
|||||||
{
|
{
|
||||||
var useTracing = _tracer != null && options.UseTracing;
|
var useTracing = _tracer != null && options.UseTracing;
|
||||||
|
|
||||||
|
//be sure that maxConnectionPerServer is in correct range of values
|
||||||
|
int maxConnectionPerServer = (options.MaxConnectionsPerServer > 0) ? maxConnectionPerServer = options.MaxConnectionsPerServer : maxConnectionPerServer = int.MaxValue;
|
||||||
|
|
||||||
return new HttpHandlerOptions(options.AllowAutoRedirect,
|
return new HttpHandlerOptions(options.AllowAutoRedirect,
|
||||||
options.UseCookieContainer, useTracing, options.UseProxy);
|
options.UseCookieContainer, useTracing, options.UseProxy, maxConnectionPerServer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace Ocelot.Configuration.Creator
|
|||||||
{
|
{
|
||||||
return new RateLimitOptionsBuilder()
|
return new RateLimitOptionsBuilder()
|
||||||
.WithClientIdHeader(globalConfiguration.RateLimitOptions.ClientIdHeader)
|
.WithClientIdHeader(globalConfiguration.RateLimitOptions.ClientIdHeader)
|
||||||
.WithClientWhiteList(fileRateLimitRule.ClientWhitelist)
|
.WithClientWhiteList(() => fileRateLimitRule.ClientWhitelist)
|
||||||
.WithDisableRateLimitHeaders(globalConfiguration.RateLimitOptions.DisableRateLimitHeaders)
|
.WithDisableRateLimitHeaders(globalConfiguration.RateLimitOptions.DisableRateLimitHeaders)
|
||||||
.WithEnableRateLimiting(fileRateLimitRule.EnableRateLimiting)
|
.WithEnableRateLimiting(fileRateLimitRule.EnableRateLimiting)
|
||||||
.WithHttpStatusCode(globalConfiguration.RateLimitOptions.HttpStatusCode)
|
.WithHttpStatusCode(globalConfiguration.RateLimitOptions.HttpStatusCode)
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
AllowAutoRedirect = false;
|
AllowAutoRedirect = false;
|
||||||
UseCookieContainer = false;
|
UseCookieContainer = false;
|
||||||
UseProxy = true;
|
UseProxy = true;
|
||||||
|
MaxConnectionsPerServer = int.MaxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AllowAutoRedirect { get; set; }
|
public bool AllowAutoRedirect { get; set; }
|
||||||
@ -16,5 +17,7 @@
|
|||||||
public bool UseTracing { get; set; }
|
public bool UseTracing { get; set; }
|
||||||
|
|
||||||
public bool UseProxy { get; set; }
|
public bool UseProxy { get; set; }
|
||||||
|
|
||||||
|
public int MaxConnectionsPerServer { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,32 +6,44 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class HttpHandlerOptions
|
public class HttpHandlerOptions
|
||||||
{
|
{
|
||||||
public HttpHandlerOptions(bool allowAutoRedirect, bool useCookieContainer, bool useTracing, bool useProxy)
|
public HttpHandlerOptions(bool allowAutoRedirect, bool useCookieContainer, bool useTracing, bool useProxy, int maxConnectionsPerServer)
|
||||||
{
|
{
|
||||||
AllowAutoRedirect = allowAutoRedirect;
|
AllowAutoRedirect = allowAutoRedirect;
|
||||||
UseCookieContainer = useCookieContainer;
|
UseCookieContainer = useCookieContainer;
|
||||||
UseTracing = useTracing;
|
UseTracing = useTracing;
|
||||||
UseProxy = useProxy;
|
UseProxy = useProxy;
|
||||||
|
MaxConnectionsPerServer = maxConnectionsPerServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specify if auto redirect is enabled
|
/// Specify if auto redirect is enabled
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <value>AllowAutoRedirect</value>
|
||||||
public bool AllowAutoRedirect { get; private set; }
|
public bool AllowAutoRedirect { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specify is handler has to use a cookie container
|
/// Specify is handler has to use a cookie container
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <value>UseCookieContainer</value>
|
||||||
public bool UseCookieContainer { get; private set; }
|
public bool UseCookieContainer { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specify is handler has to use a opentracing
|
/// Specify is handler has to use a opentracing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <value>UseTracing</value>
|
||||||
public bool UseTracing { get; private set; }
|
public bool UseTracing { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specify if handler has to use a proxy
|
/// Specify if handler has to use a proxy
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <value>UseProxy</value>
|
||||||
public bool UseProxy { get; private set; }
|
public bool UseProxy { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Specify the maximum of concurrent connection to a network endpoint
|
||||||
|
/// </summary>
|
||||||
|
/// <value>MaxConnectionsPerServer</value>
|
||||||
|
public int MaxConnectionsPerServer { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
private bool _useCookieContainer;
|
private bool _useCookieContainer;
|
||||||
private bool _useTracing;
|
private bool _useTracing;
|
||||||
private bool _useProxy;
|
private bool _useProxy;
|
||||||
|
private int _maxConnectionPerServer;
|
||||||
|
|
||||||
public HttpHandlerOptionsBuilder WithAllowAutoRedirect(bool input)
|
public HttpHandlerOptionsBuilder WithAllowAutoRedirect(bool input)
|
||||||
{
|
{
|
||||||
@ -30,10 +31,16 @@
|
|||||||
_useProxy = useProxy;
|
_useProxy = useProxy;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public HttpHandlerOptionsBuilder WithUseMaxConnectionPerServer(int maxConnectionPerServer)
|
||||||
|
{
|
||||||
|
_maxConnectionPerServer = maxConnectionPerServer;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public HttpHandlerOptions Build()
|
public HttpHandlerOptions Build()
|
||||||
{
|
{
|
||||||
return new HttpHandlerOptions(_allowAutoRedirect, _useCookieContainer, _useTracing, _useProxy);
|
return new HttpHandlerOptions(_allowAutoRedirect, _useCookieContainer, _useTracing, _useProxy, _maxConnectionPerServer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Ocelot.Configuration
|
namespace Ocelot.Configuration
|
||||||
{
|
{
|
||||||
@ -7,12 +8,14 @@ namespace Ocelot.Configuration
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class RateLimitOptions
|
public class RateLimitOptions
|
||||||
{
|
{
|
||||||
public RateLimitOptions(bool enbleRateLimiting, string clientIdHeader, List<string> clientWhitelist, bool disableRateLimitHeaders,
|
private readonly Func<List<string>> _getClientWhitelist;
|
||||||
|
|
||||||
|
public RateLimitOptions(bool enableRateLimiting, string clientIdHeader, Func<List<string>> getClientWhitelist, bool disableRateLimitHeaders,
|
||||||
string quotaExceededMessage, string rateLimitCounterPrefix, RateLimitRule rateLimitRule, int httpStatusCode)
|
string quotaExceededMessage, string rateLimitCounterPrefix, RateLimitRule rateLimitRule, int httpStatusCode)
|
||||||
{
|
{
|
||||||
EnableRateLimiting = enbleRateLimiting;
|
EnableRateLimiting = enableRateLimiting;
|
||||||
ClientIdHeader = clientIdHeader;
|
ClientIdHeader = clientIdHeader;
|
||||||
ClientWhitelist = clientWhitelist ?? new List<string>();
|
_getClientWhitelist = getClientWhitelist;
|
||||||
DisableRateLimitHeaders = disableRateLimitHeaders;
|
DisableRateLimitHeaders = disableRateLimitHeaders;
|
||||||
QuotaExceededMessage = quotaExceededMessage;
|
QuotaExceededMessage = quotaExceededMessage;
|
||||||
RateLimitCounterPrefix = rateLimitCounterPrefix;
|
RateLimitCounterPrefix = rateLimitCounterPrefix;
|
||||||
@ -22,7 +25,10 @@ namespace Ocelot.Configuration
|
|||||||
|
|
||||||
public RateLimitRule RateLimitRule { get; private set; }
|
public RateLimitRule RateLimitRule { get; private set; }
|
||||||
|
|
||||||
public List<string> ClientWhitelist { get; private set; }
|
/// <summary>
|
||||||
|
/// Gets the list of white listed clients
|
||||||
|
/// </summary>
|
||||||
|
public List<string> ClientWhitelist { get => _getClientWhitelist(); }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the HTTP header that holds the client identifier, by default is X-ClientId
|
/// Gets or sets the HTTP header that holds the client identifier, by default is X-ClientId
|
||||||
|
@ -105,7 +105,8 @@ namespace Ocelot.Configuration.Repository
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_timer.Dispose();
|
_timer?.Dispose();
|
||||||
|
_timer = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
public class FileConfigurationFluentValidator : AbstractValidator<FileConfiguration>, IConfigurationValidator
|
public class FileConfigurationFluentValidator : AbstractValidator<FileConfiguration>, IConfigurationValidator
|
||||||
@ -35,6 +36,10 @@
|
|||||||
.Must((config, reRoute) => HaveServiceDiscoveryProviderRegistered(reRoute, config.GlobalConfiguration.ServiceDiscoveryProvider))
|
.Must((config, reRoute) => HaveServiceDiscoveryProviderRegistered(reRoute, config.GlobalConfiguration.ServiceDiscoveryProvider))
|
||||||
.WithMessage((config, reRoute) => $"Unable to start Ocelot, errors are: Unable to start Ocelot because either a ReRoute or GlobalConfiguration are using ServiceDiscoveryOptions but no ServiceDiscoveryFinderDelegate has been registered in dependency injection container. Are you missing a package like Ocelot.Provider.Consul and services.AddConsul() or Ocelot.Provider.Eureka and services.AddEureka()?");
|
.WithMessage((config, reRoute) => $"Unable to start Ocelot, errors are: Unable to start Ocelot because either a ReRoute or GlobalConfiguration are using ServiceDiscoveryOptions but no ServiceDiscoveryFinderDelegate has been registered in dependency injection container. Are you missing a package like Ocelot.Provider.Consul and services.AddConsul() or Ocelot.Provider.Eureka and services.AddEureka()?");
|
||||||
|
|
||||||
|
RuleForEach(configuration => configuration.ReRoutes)
|
||||||
|
.Must((config, reRoute) => IsPlaceholderNotDuplicatedIn(reRoute.UpstreamPathTemplate))
|
||||||
|
.WithMessage((config, reRoute) => $"{nameof(reRoute)} {reRoute.UpstreamPathTemplate} has duplicated placeholder");
|
||||||
|
|
||||||
RuleFor(configuration => configuration.GlobalConfiguration.ServiceDiscoveryProvider)
|
RuleFor(configuration => configuration.GlobalConfiguration.ServiceDiscoveryProvider)
|
||||||
.Must(HaveServiceDiscoveryProviderRegistered)
|
.Must(HaveServiceDiscoveryProviderRegistered)
|
||||||
.WithMessage((config, reRoute) => $"Unable to start Ocelot, errors are: Unable to start Ocelot because either a ReRoute or GlobalConfiguration are using ServiceDiscoveryOptions but no ServiceDiscoveryFinderDelegate has been registered in dependency injection container. Are you missing a package like Ocelot.Provider.Consul and services.AddConsul() or Ocelot.Provider.Eureka and services.AddEureka()?");
|
.WithMessage((config, reRoute) => $"Unable to start Ocelot, errors are: Unable to start Ocelot because either a ReRoute or GlobalConfiguration are using ServiceDiscoveryOptions but no ServiceDiscoveryFinderDelegate has been registered in dependency injection container. Are you missing a package like Ocelot.Provider.Consul and services.AddConsul() or Ocelot.Provider.Eureka and services.AddEureka()?");
|
||||||
@ -109,6 +114,14 @@
|
|||||||
return reRoutesForAggregate.Count() == fileAggregateReRoute.ReRouteKeys.Count;
|
return reRoutesForAggregate.Count() == fileAggregateReRoute.ReRouteKeys.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsPlaceholderNotDuplicatedIn(string upstreamPathTemplate)
|
||||||
|
{
|
||||||
|
Regex regExPlaceholder = new Regex("{[^}]+}");
|
||||||
|
var matches = regExPlaceholder.Matches(upstreamPathTemplate);
|
||||||
|
var upstreamPathPlaceholders = matches.Select(m => m.Value);
|
||||||
|
return upstreamPathPlaceholders.Count() == upstreamPathPlaceholders.Distinct().Count();
|
||||||
|
}
|
||||||
|
|
||||||
private static bool DoesNotContainReRoutesWithSpecificRequestIdKeys(FileAggregateReRoute fileAggregateReRoute,
|
private static bool DoesNotContainReRoutesWithSpecificRequestIdKeys(FileAggregateReRoute fileAggregateReRoute,
|
||||||
List<FileReRoute> reRoutes)
|
List<FileReRoute> reRoutes)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,10 @@ namespace Ocelot.DownstreamUrlCreator.Middleware
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(context.DownstreamReRoute.DownstreamScheme))
|
||||||
|
{
|
||||||
context.DownstreamRequest.Scheme = context.DownstreamReRoute.DownstreamScheme;
|
context.DownstreamRequest.Scheme = context.DownstreamReRoute.DownstreamScheme;
|
||||||
|
}
|
||||||
|
|
||||||
if (ServiceFabricRequest(context))
|
if (ServiceFabricRequest(context))
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,11 @@ namespace Ocelot.LoadBalancer.Middleware
|
|||||||
context.DownstreamRequest.Port = hostAndPort.Data.DownstreamPort;
|
context.DownstreamRequest.Port = hostAndPort.Data.DownstreamPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(hostAndPort.Data.Scheme))
|
||||||
|
{
|
||||||
|
context.DownstreamRequest.Scheme = hostAndPort.Data.Scheme;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await _next.Invoke(context);
|
await _next.Invoke(context);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<NoPackageAnalysis>true</NoPackageAnalysis>
|
<NoPackageAnalysis>true</NoPackageAnalysis>
|
||||||
<Description>Ocelot is an API Gateway. The project is aimed at people using .NET running a micro services / service orientated architecture that need a unified point of entry into their system. In particular I want easy integration with IdentityServer reference and bearer tokens. reference tokens. Ocelot is a bunch of middlewares in a specific order. Ocelot manipulates the HttpRequest object into a state specified by its configuration until it reaches a request builder middleware where it creates a HttpRequestMessage object which is used to make a request to a downstream service. The middleware that makes the request is the last thing in the Ocelot pipeline. It does not call the next middleware. The response from the downstream service is stored in a per request scoped repository and retrived as the requests goes back up the Ocelot pipeline. There is a piece of middleware that maps the HttpResponseMessage onto the HttpResponse object and that is returned to the client. That is basically it with a bunch of other features.</Description>
|
<Description>Ocelot is an API Gateway. The project is aimed at people using .NET running a micro services / service orientated architecture that need a unified point of entry into their system. In particular I want easy integration with IdentityServer reference and bearer tokens. reference tokens. Ocelot is a bunch of middlewares in a specific order. Ocelot manipulates the HttpRequest object into a state specified by its configuration until it reaches a request builder middleware where it creates a HttpRequestMessage object which is used to make a request to a downstream service. The middleware that makes the request is the last thing in the Ocelot pipeline. It does not call the next middleware. The response from the downstream service is stored in a per request scoped repository and retrived as the requests goes back up the Ocelot pipeline. There is a piece of middleware that maps the HttpResponseMessage onto the HttpResponse object and that is returned to the client. That is basically it with a bunch of other features.</Description>
|
||||||
<AssemblyTitle>Ocelot</AssemblyTitle>
|
<AssemblyTitle>Ocelot</AssemblyTitle>
|
||||||
@ -36,7 +36,7 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -90,7 +90,9 @@ namespace Ocelot.Requester
|
|||||||
{
|
{
|
||||||
AllowAutoRedirect = context.DownstreamReRoute.HttpHandlerOptions.AllowAutoRedirect,
|
AllowAutoRedirect = context.DownstreamReRoute.HttpHandlerOptions.AllowAutoRedirect,
|
||||||
UseCookies = context.DownstreamReRoute.HttpHandlerOptions.UseCookieContainer,
|
UseCookies = context.DownstreamReRoute.HttpHandlerOptions.UseCookieContainer,
|
||||||
UseProxy = context.DownstreamReRoute.HttpHandlerOptions.UseProxy
|
UseProxy = context.DownstreamReRoute.HttpHandlerOptions.UseProxy,
|
||||||
|
MaxConnectionsPerServer = context.DownstreamReRoute.HttpHandlerOptions.MaxConnectionsPerServer
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,6 +103,7 @@ namespace Ocelot.Requester
|
|||||||
AllowAutoRedirect = context.DownstreamReRoute.HttpHandlerOptions.AllowAutoRedirect,
|
AllowAutoRedirect = context.DownstreamReRoute.HttpHandlerOptions.AllowAutoRedirect,
|
||||||
UseCookies = context.DownstreamReRoute.HttpHandlerOptions.UseCookieContainer,
|
UseCookies = context.DownstreamReRoute.HttpHandlerOptions.UseCookieContainer,
|
||||||
UseProxy = context.DownstreamReRoute.HttpHandlerOptions.UseProxy,
|
UseProxy = context.DownstreamReRoute.HttpHandlerOptions.UseProxy,
|
||||||
|
MaxConnectionsPerServer = context.DownstreamReRoute.HttpHandlerOptions.MaxConnectionsPerServer,
|
||||||
CookieContainer = new CookieContainer()
|
CookieContainer = new CookieContainer()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
namespace Ocelot.Requester
|
namespace Ocelot.Requester
|
||||||
{
|
{
|
||||||
using Errors;
|
using Ocelot.Errors;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -23,7 +23,7 @@ namespace Ocelot.Requester
|
|||||||
return _mappers[type](exception);
|
return _mappers[type](exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == typeof(OperationCanceledException))
|
if (type == typeof(OperationCanceledException) || type.IsSubclassOf(typeof(OperationCanceledException)))
|
||||||
{
|
{
|
||||||
return new RequestCanceledError(exception.Message);
|
return new RequestCanceledError(exception.Message);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
using Ocelot.Logging;
|
using Ocelot.Logging;
|
||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Ocelot.Responses;
|
||||||
|
|
||||||
namespace Ocelot.Requester.Middleware
|
namespace Ocelot.Requester.Middleware
|
||||||
{
|
{
|
||||||
@ -22,6 +25,8 @@ namespace Ocelot.Requester.Middleware
|
|||||||
{
|
{
|
||||||
var response = await _requester.GetResponse(context);
|
var response = await _requester.GetResponse(context);
|
||||||
|
|
||||||
|
CreateLogBasedOnResponse(response);
|
||||||
|
|
||||||
if (response.IsError)
|
if (response.IsError)
|
||||||
{
|
{
|
||||||
Logger.LogDebug("IHttpRequester returned an error, setting pipeline error");
|
Logger.LogDebug("IHttpRequester returned an error, setting pipeline error");
|
||||||
@ -36,5 +41,19 @@ namespace Ocelot.Requester.Middleware
|
|||||||
|
|
||||||
await _next.Invoke(context);
|
await _next.Invoke(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CreateLogBasedOnResponse(Response<HttpResponseMessage> response)
|
||||||
|
{
|
||||||
|
if (response.Data?.StatusCode <= HttpStatusCode.BadRequest)
|
||||||
|
{
|
||||||
|
Logger.LogInformation(
|
||||||
|
$"{(int)response.Data.StatusCode} ({response.Data.ReasonPhrase}) status code, request uri: {response.Data.RequestMessage?.RequestUri}");
|
||||||
|
}
|
||||||
|
else if (response.Data?.StatusCode >= HttpStatusCode.BadRequest)
|
||||||
|
{
|
||||||
|
Logger.LogWarning(
|
||||||
|
$"{(int) response.Data.StatusCode} ({response.Data.ReasonPhrase}) status code, request uri: {response.Data.RequestMessage?.RequestUri}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ namespace Ocelot.ServiceDiscovery
|
|||||||
|
|
||||||
foreach (var downstreamAddress in reRoute.DownstreamAddresses)
|
foreach (var downstreamAddress in reRoute.DownstreamAddresses)
|
||||||
{
|
{
|
||||||
var service = new Service(reRoute.ServiceName, new ServiceHostAndPort(downstreamAddress.Host, downstreamAddress.Port), string.Empty, string.Empty, new string[0]);
|
var service = new Service(reRoute.ServiceName, new ServiceHostAndPort(downstreamAddress.Host, downstreamAddress.Port, reRoute.DownstreamScheme), string.Empty, string.Empty, new string[0]);
|
||||||
|
|
||||||
services.Add(service);
|
services.Add(service);
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,13 @@
|
|||||||
DownstreamPort = downstreamPort;
|
DownstreamPort = downstreamPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ServiceHostAndPort(string downstreamHost, int downstreamPort, string scheme)
|
||||||
|
: this(downstreamHost, downstreamPort) => Scheme = scheme;
|
||||||
|
|
||||||
public string DownstreamHost { get; }
|
public string DownstreamHost { get; }
|
||||||
|
|
||||||
public int DownstreamPort { get; }
|
public int DownstreamPort { get; }
|
||||||
|
|
||||||
|
public string Scheme { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -170,7 +170,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51890,
|
Port = 54030,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/UserDetails",
|
UpstreamPathTemplate = "/UserDetails",
|
||||||
@ -222,7 +222,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
var expected = "{\"Comments\":" + commentsResponseContent + ",\"UserDetails\":" + userDetailsResponseContent + ",\"PostDetails\":" + postDetailsResponseContent + "}";
|
var expected = "{\"Comments\":" + commentsResponseContent + ",\"UserDetails\":" + userDetailsResponseContent + ",\"PostDetails\":" + postDetailsResponseContent + "}";
|
||||||
|
|
||||||
this.Given(x => x.GivenServiceOneIsRunning("http://localhost:51889", "/", 200, commentsResponseContent))
|
this.Given(x => x.GivenServiceOneIsRunning("http://localhost:51889", "/", 200, commentsResponseContent))
|
||||||
.Given(x => x.GivenServiceTwoIsRunning("http://localhost:51890", "/users/1", 200, userDetailsResponseContent))
|
.Given(x => x.GivenServiceTwoIsRunning("http://localhost:54030", "/users/1", 200, userDetailsResponseContent))
|
||||||
.Given(x => x.GivenServiceTwoIsRunning("http://localhost:51887", "/posts/2", 200, postDetailsResponseContent))
|
.Given(x => x.GivenServiceTwoIsRunning("http://localhost:51887", "/posts/2", 200, postDetailsResponseContent))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
@ -333,7 +333,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51886,
|
Port = 52476,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/tom",
|
UpstreamPathTemplate = "/tom",
|
||||||
@ -359,7 +359,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
var expected = "{\"Laura\":{Hello from Laura},\"Tom\":{Hello from Tom}}";
|
var expected = "{\"Laura\":{Hello from Laura},\"Tom\":{Hello from Tom}}";
|
||||||
|
|
||||||
this.Given(x => x.GivenServiceOneIsRunning("http://localhost:51875", "/", 200, "{Hello from Laura}"))
|
this.Given(x => x.GivenServiceOneIsRunning("http://localhost:51875", "/", 200, "{Hello from Laura}"))
|
||||||
.Given(x => x.GivenServiceTwoIsRunning("http://localhost:51886", "/", 200, "{Hello from Tom}"))
|
.Given(x => x.GivenServiceTwoIsRunning("http://localhost:52476", "/", 200, "{Hello from Tom}"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
@ -401,7 +401,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51882,
|
Port = 51889,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/tom",
|
UpstreamPathTemplate = "/tom",
|
||||||
@ -427,7 +427,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
var expected = "{\"Laura\":,\"Tom\":{Hello from Tom}}";
|
var expected = "{\"Laura\":,\"Tom\":{Hello from Tom}}";
|
||||||
|
|
||||||
this.Given(x => x.GivenServiceOneIsRunning("http://localhost:51881", "/", 404, ""))
|
this.Given(x => x.GivenServiceOneIsRunning("http://localhost:51881", "/", 404, ""))
|
||||||
.Given(x => x.GivenServiceTwoIsRunning("http://localhost:51882", "/", 200, "{Hello from Tom}"))
|
.Given(x => x.GivenServiceTwoIsRunning("http://localhost:51889", "/", 200, "{Hello from Tom}"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
|
@ -35,7 +35,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51899,
|
Port = 57899,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DownstreamScheme = "http",
|
DownstreamScheme = "http",
|
||||||
@ -49,13 +49,13 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51899", 200, "Hello from Laura", null, null))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:57899", 200, "Hello from Laura", null, null))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
||||||
.And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
|
.And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
|
||||||
.Given(x => x.GivenTheServiceNowReturns("http://localhost:51899", 200, "Hello from Tom"))
|
.Given(x => x.GivenTheServiceNowReturns("http://localhost:57899", 200, "Hello from Tom"))
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
||||||
.And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
|
.And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
|
||||||
@ -122,7 +122,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51899,
|
Port = 57879,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DownstreamScheme = "http",
|
DownstreamScheme = "http",
|
||||||
@ -136,13 +136,13 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51899", 200, "Hello from Laura", null, null))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:57879", 200, "Hello from Laura", null, null))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunningUsingJsonSerializedCache())
|
.And(x => _steps.GivenOcelotIsRunningUsingJsonSerializedCache())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
||||||
.And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
|
.And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
|
||||||
.Given(x => x.GivenTheServiceNowReturns("http://localhost:51899", 200, "Hello from Tom"))
|
.Given(x => x.GivenTheServiceNowReturns("http://localhost:57879", 200, "Hello from Tom"))
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
||||||
.And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
|
.And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
|
||||||
@ -164,7 +164,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51899,
|
Port = 57873,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DownstreamScheme = "http",
|
DownstreamScheme = "http",
|
||||||
@ -178,13 +178,13 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51899", 200, "Hello from Laura", null, null))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:57873", 200, "Hello from Laura", null, null))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
||||||
.And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
|
.And(x => _steps.ThenTheResponseBodyShouldBe("Hello from Laura"))
|
||||||
.Given(x => x.GivenTheServiceNowReturns("http://localhost:51899", 200, "Hello from Tom"))
|
.Given(x => x.GivenTheServiceNowReturns("http://localhost:57873", 200, "Hello from Tom"))
|
||||||
.And(x => x.GivenTheCacheExpires())
|
.And(x => x.GivenTheCacheExpires())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
.Then(x => _steps.ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
||||||
|
@ -39,7 +39,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 51179,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/",
|
UpstreamPathTemplate = "/",
|
||||||
@ -50,7 +50,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
|
|
||||||
var input = "people";
|
var input = "people";
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/", 200, "Hello from Laura", "\"people\""))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51179", "/", 200, "Hello from Laura", "\"people\""))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.And(x => _steps.GivenThePostHasGzipContent(input))
|
.And(x => _steps.GivenThePostHasGzipContent(input))
|
||||||
|
@ -327,7 +327,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 52866,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/",
|
UpstreamPathTemplate = "/",
|
||||||
@ -336,7 +336,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/", 200, "Accept"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:52866", "/", 200, "Accept"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.And(x => _steps.GivenIAddAHeader("Accept", "text/html,application/xhtml+xml,application/xml;"))
|
.And(x => _steps.GivenIAddAHeader("Accept", "text/html,application/xhtml+xml,application/xml;"))
|
||||||
@ -362,7 +362,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 51874,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/",
|
UpstreamPathTemplate = "/",
|
||||||
@ -371,7 +371,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/", 200, "Accept"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51874", "/", 200, "Accept"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.And(x => _steps.GivenIAddAHeader("Accept", "text/html"))
|
.And(x => _steps.GivenIAddAHeader("Accept", "text/html"))
|
||||||
|
@ -40,7 +40,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 58814,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/",
|
UpstreamPathTemplate = "/",
|
||||||
@ -51,7 +51,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
|
|
||||||
var cache = new FakeHttpClientCache();
|
var cache = new FakeHttpClientCache();
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", 200, "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:58814", 200, "Hello from Laura"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunningWithFakeHttpClientCache(cache))
|
.And(x => _steps.GivenOcelotIsRunningWithFakeHttpClientCache(cache))
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
@ -80,7 +80,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 58817,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/",
|
UpstreamPathTemplate = "/",
|
||||||
@ -95,7 +95,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 58817,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/two",
|
UpstreamPathTemplate = "/two",
|
||||||
@ -106,7 +106,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
|
|
||||||
var cache = new FakeHttpClientCache();
|
var cache = new FakeHttpClientCache();
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", 200, "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:58817", 200, "Hello from Laura"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunningWithFakeHttpClientCache(cache))
|
.And(x => _steps.GivenOcelotIsRunningWithFakeHttpClientCache(cache))
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VersionPrefix>0.0.0-dev</VersionPrefix>
|
<VersionPrefix>0.0.0-dev</VersionPrefix>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<AssemblyName>Ocelot.AcceptanceTests</AssemblyName>
|
<AssemblyName>Ocelot.AcceptanceTests</AssemblyName>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<PackageId>Ocelot.AcceptanceTests</PackageId>
|
<PackageId>Ocelot.AcceptanceTests</PackageId>
|
||||||
@ -40,6 +40,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.0.0" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
|
||||||
|
<PackageReference Include="Moq" Version="4.13.0" />
|
||||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
|
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.66">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
@ -69,6 +70,6 @@
|
|||||||
<PackageReference Include="Pivotal.Discovery.ClientCore" Version="2.2.0" />
|
<PackageReference Include="Pivotal.Discovery.ClientCore" Version="2.2.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -166,7 +166,7 @@
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51872,
|
Port = 51870,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/",
|
UpstreamPathTemplate = "/",
|
||||||
@ -196,7 +196,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAPossiblyBrokenServiceRunningOn("http://localhost:51872", "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAPossiblyBrokenServiceRunningOn("http://localhost:51870", "Hello from Laura"))
|
||||||
.And(x => x.GivenThereIsAServiceRunningOn("http://localhost:51880/", 200, "Hello from Tom", 0))
|
.And(x => x.GivenThereIsAServiceRunningOn("http://localhost:51880/", 200, "Hello from Tom", 0))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunningWithPolly())
|
.And(x => _steps.GivenOcelotIsRunningWithPolly())
|
||||||
|
@ -34,7 +34,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 51092,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/{everything}",
|
UpstreamPathTemplate = "/{everything}",
|
||||||
@ -43,7 +43,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/inline.132.bundle.js", 304))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51092", "/inline.132.bundle.js", 304))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/inline.132.bundle.js"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/inline.132.bundle.js"))
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void should_return_internal_server_error_if_downstream_service_returns_internal_server_error()
|
public void should_return_internal_server_error_if_downstream_service_returns_internal_server_error()
|
||||||
{
|
{
|
||||||
|
|
||||||
var configuration = new FileConfiguration
|
var configuration = new FileConfiguration
|
||||||
{
|
{
|
||||||
ReRoutes = new List<FileReRoute>
|
ReRoutes = new List<FileReRoute>
|
||||||
@ -51,6 +52,39 @@
|
|||||||
.BDDfy();
|
.BDDfy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void should_log_warning_if_downstream_service_returns_internal_server_error()
|
||||||
|
{
|
||||||
|
var configuration = new FileConfiguration
|
||||||
|
{
|
||||||
|
ReRoutes = new List<FileReRoute>
|
||||||
|
{
|
||||||
|
new FileReRoute
|
||||||
|
{
|
||||||
|
DownstreamPathTemplate = "/",
|
||||||
|
UpstreamPathTemplate = "/",
|
||||||
|
UpstreamHttpMethod = new List<string> { "Get" },
|
||||||
|
DownstreamHostAndPorts = new List<FileHostAndPort>
|
||||||
|
{
|
||||||
|
new FileHostAndPort
|
||||||
|
{
|
||||||
|
Host = "localhost",
|
||||||
|
Port = 53876,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
DownstreamScheme = "http",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:53876"))
|
||||||
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
|
.And(x => _steps.GivenOcelotIsRunningWithLogger())
|
||||||
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
|
.Then(x => _steps.ThenWarningShouldBeLogged())
|
||||||
|
.BDDfy();
|
||||||
|
}
|
||||||
|
|
||||||
private void GivenThereIsAServiceRunningOn(string url)
|
private void GivenThereIsAServiceRunningOn(string url)
|
||||||
{
|
{
|
||||||
_serviceHandler.GivenThereIsAServiceRunningOn(url, context => throw new Exception("BLAMMMM"));
|
_serviceHandler.GivenThereIsAServiceRunningOn(url, context => throw new Exception("BLAMMMM"));
|
||||||
|
@ -84,14 +84,14 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 57873,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879/", "/", 200, "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:57873/", "/", 200, "Hello from Laura"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
@ -131,7 +131,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 50810,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/",
|
UpstreamPathTemplate = "/",
|
||||||
@ -180,7 +180,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 50810,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/",
|
UpstreamPathTemplate = "/",
|
||||||
@ -189,7 +189,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879/", "/", 200, "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:50810/", "/", 200, "Hello from Laura"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
@ -263,7 +263,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 51005,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/{url}",
|
UpstreamPathTemplate = "/{url}",
|
||||||
@ -272,7 +272,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/", 200, "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51005", "/", 200, "Hello from Laura"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway(""))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway(""))
|
||||||
@ -297,7 +297,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 58589,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/",
|
UpstreamPathTemplate = "/",
|
||||||
@ -306,7 +306,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/", 200, "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:58589", "/", 200, "Hello from Laura"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
@ -382,7 +382,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 51206,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/",
|
UpstreamPathTemplate = "/",
|
||||||
@ -391,7 +391,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/api/products", 200, "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51206", "/api/products", 200, "Hello from Laura"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
@ -416,7 +416,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 51990,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/",
|
UpstreamPathTemplate = "/",
|
||||||
@ -425,7 +425,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/api/products", 200, "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51990", "/api/products", 200, "Hello from Laura"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
@ -450,7 +450,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 58804,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/products/",
|
UpstreamPathTemplate = "/products/",
|
||||||
@ -459,7 +459,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/products", 200, "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:58804", "/products", 200, "Hello from Laura"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/products"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/products"))
|
||||||
@ -484,7 +484,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 54015,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/products",
|
UpstreamPathTemplate = "/products",
|
||||||
@ -493,7 +493,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/products", 200, "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:54015", "/products", 200, "Hello from Laura"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/products/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/products/"))
|
||||||
@ -517,7 +517,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 54072,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/products/{productId}",
|
UpstreamPathTemplate = "/products/{productId}",
|
||||||
@ -526,7 +526,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/products", 200, "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:54072", "/products", 200, "Hello from Laura"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/products/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/products/"))
|
||||||
@ -550,7 +550,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 55961,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/products/{productId}",
|
UpstreamPathTemplate = "/products/{productId}",
|
||||||
@ -559,7 +559,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/api/products/1", 200, "Some Product"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:55961", "/api/products/1", 200, "Some Product"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/products/1"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/products/1"))
|
||||||
@ -584,7 +584,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 51116,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/{variantId}/products/{productId}",
|
UpstreamPathTemplate = "/{variantId}/products/{productId}",
|
||||||
@ -593,7 +593,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/api/23/products/1", 200, "Some Product"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51116", "/api/23/products/1", 200, "Some Product"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("23/products/1"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("23/products/1"))
|
||||||
@ -618,7 +618,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 51809,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/products/{productId}",
|
UpstreamPathTemplate = "/products/{productId}",
|
||||||
@ -627,7 +627,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => GivenThereIsAServiceRunningOn("http://localhost:51879", "/api/products/1", 200, "Some Product"))
|
this.Given(x => GivenThereIsAServiceRunningOn("http://localhost:51809", "/api/products/1", 200, "Some Product"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/products/1"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/products/1"))
|
||||||
@ -650,7 +650,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 56615,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DownstreamScheme = "http",
|
DownstreamScheme = "http",
|
||||||
@ -660,7 +660,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/", 201, string.Empty))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:56615", "/", 201, string.Empty))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.And(x => _steps.GivenThePostHasContent("postContent"))
|
.And(x => _steps.GivenThePostHasContent("postContent"))
|
||||||
@ -686,7 +686,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 57771,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamHttpMethod = new List<string> { "Get" },
|
UpstreamHttpMethod = new List<string> { "Get" },
|
||||||
@ -694,7 +694,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/newThing", 200, "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:57771", "/newThing", 200, "Hello from Laura"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/newThing?DeviceType=IphoneApp&Browser=moonpigIphone&BrowserString=-&CountryCode=123&DeviceName=iPhone 5 (GSM+CDMA)&OperatingSystem=iPhone OS 7.1.2&BrowserVersion=3708AdHoc&ipAddress=-"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/newThing?DeviceType=IphoneApp&Browser=moonpigIphone&BrowserString=-&CountryCode=123&DeviceName=iPhone 5 (GSM+CDMA)&OperatingSystem=iPhone OS 7.1.2&BrowserVersion=3708AdHoc&ipAddress=-"))
|
||||||
@ -719,7 +719,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 55609,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/myApp1Name/api/{urlPath}",
|
UpstreamPathTemplate = "/myApp1Name/api/{urlPath}",
|
||||||
@ -728,7 +728,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/api/products/1", 200, "Some Product"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:55609", "/api/products/1", 200, "Some Product"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/myApp1Name/api/products/1"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/myApp1Name/api/products/1"))
|
||||||
@ -752,7 +752,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 59911,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DownstreamScheme = "http",
|
DownstreamScheme = "http",
|
||||||
@ -762,7 +762,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "", 201, string.Empty))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:59911", "", 201, string.Empty))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.And(x => _steps.GivenThePostHasContent("postContent"))
|
.And(x => _steps.GivenThePostHasContent("postContent"))
|
||||||
@ -786,7 +786,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 59187,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DownstreamScheme = "http",
|
DownstreamScheme = "http",
|
||||||
@ -796,7 +796,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/", 200, "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:59187", "/", 200, "Hello from Laura"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("/"))
|
||||||
@ -821,7 +821,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 54079,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/vacancy/",
|
UpstreamPathTemplate = "/vacancy/",
|
||||||
@ -837,7 +837,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 54079,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/vacancy/{vacancyId}",
|
UpstreamPathTemplate = "/vacancy/{vacancyId}",
|
||||||
@ -847,7 +847,7 @@ namespace Ocelot.AcceptanceTests
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:51879", "/api/v1/vacancy/1", 200, "Hello from Laura"))
|
this.Given(x => x.GivenThereIsAServiceRunningOn("http://localhost:54079", "/api/v1/vacancy/1", 200, "Hello from Laura"))
|
||||||
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
.And(x => _steps.GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => _steps.GivenOcelotIsRunning())
|
.And(x => _steps.GivenOcelotIsRunning())
|
||||||
.When(x => _steps.WhenIGetUrlOnTheApiGateway("api/vacancy/1"))
|
.When(x => _steps.WhenIGetUrlOnTheApiGateway("api/vacancy/1"))
|
||||||
|
@ -10,12 +10,14 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Moq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Ocelot.Cache.CacheManager;
|
using Ocelot.Cache.CacheManager;
|
||||||
using Ocelot.Configuration.Creator;
|
using Ocelot.Configuration.Creator;
|
||||||
using Ocelot.Configuration.File;
|
using Ocelot.Configuration.File;
|
||||||
using Ocelot.DependencyInjection;
|
using Ocelot.DependencyInjection;
|
||||||
using Ocelot.Infrastructure;
|
using Ocelot.Infrastructure;
|
||||||
|
using Ocelot.Logging;
|
||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
using Ocelot.Middleware.Multiplexer;
|
using Ocelot.Middleware.Multiplexer;
|
||||||
using Ocelot.Provider.Consul;
|
using Ocelot.Provider.Consul;
|
||||||
@ -1120,5 +1122,60 @@
|
|||||||
|
|
||||||
_ocelotClient = _ocelotServer.CreateClient();
|
_ocelotClient = _ocelotServer.CreateClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GivenOcelotIsRunningWithLogger()
|
||||||
|
{
|
||||||
|
_webHostBuilder = new WebHostBuilder();
|
||||||
|
|
||||||
|
_webHostBuilder
|
||||||
|
.ConfigureAppConfiguration((hostingContext, config) =>
|
||||||
|
{
|
||||||
|
config.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath);
|
||||||
|
var env = hostingContext.HostingEnvironment;
|
||||||
|
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
|
||||||
|
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: false);
|
||||||
|
config.AddJsonFile("ocelot.json", false, false);
|
||||||
|
config.AddEnvironmentVariables();
|
||||||
|
})
|
||||||
|
.ConfigureServices(s =>
|
||||||
|
{
|
||||||
|
s.AddOcelot();
|
||||||
|
s.AddSingleton<IOcelotLoggerFactory, MockLoggerFactory>();
|
||||||
|
})
|
||||||
|
.Configure(app =>
|
||||||
|
{
|
||||||
|
app.UseOcelot().Wait();
|
||||||
|
});
|
||||||
|
|
||||||
|
_ocelotServer = new TestServer(_webHostBuilder);
|
||||||
|
|
||||||
|
_ocelotClient = _ocelotServer.CreateClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ThenWarningShouldBeLogged()
|
||||||
|
{
|
||||||
|
MockLoggerFactory loggerFactory = (MockLoggerFactory)_ocelotServer.Host.Services.GetService<IOcelotLoggerFactory>();
|
||||||
|
loggerFactory.Verify();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class MockLoggerFactory : IOcelotLoggerFactory
|
||||||
|
{
|
||||||
|
private Mock<IOcelotLogger> _logger;
|
||||||
|
|
||||||
|
public IOcelotLogger CreateLogger<T>()
|
||||||
|
{
|
||||||
|
if (_logger == null)
|
||||||
|
{
|
||||||
|
_logger = new Mock<IOcelotLogger>();
|
||||||
|
_logger.Setup(x => x.LogWarning(It.IsAny<string>())).Verifiable();
|
||||||
|
}
|
||||||
|
return _logger.Object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Verify()
|
||||||
|
{
|
||||||
|
_logger.Verify(x => x.LogWarning(It.IsAny<string>()), Times.Once);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VersionPrefix>0.0.0-dev</VersionPrefix>
|
<VersionPrefix>0.0.0-dev</VersionPrefix>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<AssemblyName>Ocelot.Benchmarks</AssemblyName>
|
<AssemblyName>Ocelot.Benchmarks</AssemblyName>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<PackageId>Ocelot.Benchmarks</PackageId>
|
<PackageId>Ocelot.Benchmarks</PackageId>
|
||||||
@ -25,6 +25,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -107,7 +107,7 @@ namespace Ocelot.IntegrationTests
|
|||||||
.And(x => GivenIdentityServerSigningEnvironmentalVariablesAreSet())
|
.And(x => GivenIdentityServerSigningEnvironmentalVariablesAreSet())
|
||||||
.And(x => GivenOcelotIsRunning())
|
.And(x => GivenOcelotIsRunning())
|
||||||
.And(x => GivenIHaveAnOcelotToken("/administration"))
|
.And(x => GivenIHaveAnOcelotToken("/administration"))
|
||||||
.And(x => GivenAnotherOcelotIsRunning("http://localhost:5007"))
|
.And(x => GivenAnotherOcelotIsRunning("http://localhost:5017"))
|
||||||
.When(x => WhenIGetUrlOnTheSecondOcelot("/administration/configuration"))
|
.When(x => WhenIGetUrlOnTheSecondOcelot("/administration/configuration"))
|
||||||
.Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
.Then(x => ThenTheStatusCodeShouldBe(HttpStatusCode.OK))
|
||||||
.BDDfy();
|
.BDDfy();
|
||||||
|
@ -34,7 +34,7 @@ namespace Ocelot.IntegrationTests
|
|||||||
public HeaderTests()
|
public HeaderTests()
|
||||||
{
|
{
|
||||||
_httpClient = new HttpClient();
|
_httpClient = new HttpClient();
|
||||||
_ocelotBaseUrl = "http://localhost:5005";
|
_ocelotBaseUrl = "http://localhost:5010";
|
||||||
_httpClient.BaseAddress = new Uri(_ocelotBaseUrl);
|
_httpClient.BaseAddress = new Uri(_ocelotBaseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VersionPrefix>0.0.0-dev</VersionPrefix>
|
<VersionPrefix>0.0.0-dev</VersionPrefix>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<AssemblyName>Ocelot.IntegrationTests</AssemblyName>
|
<AssemblyName>Ocelot.IntegrationTests</AssemblyName>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<PackageId>Ocelot.IntegrationTests</PackageId>
|
<PackageId>Ocelot.IntegrationTests</PackageId>
|
||||||
@ -56,6 +56,6 @@
|
|||||||
<PackageReference Include="IdentityServer4" Version="3.0.1" />
|
<PackageReference Include="IdentityServer4" Version="3.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -53,7 +53,7 @@ namespace Ocelot.IntegrationTests
|
|||||||
new FileHostAndPort
|
new FileHostAndPort
|
||||||
{
|
{
|
||||||
Host = "localhost",
|
Host = "localhost",
|
||||||
Port = 51879,
|
Port = 51611,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
UpstreamPathTemplate = "/",
|
UpstreamPathTemplate = "/",
|
||||||
@ -63,7 +63,7 @@ namespace Ocelot.IntegrationTests
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => GivenThereIsAConfiguration(configuration))
|
this.Given(x => GivenThereIsAConfiguration(configuration))
|
||||||
.And(x => GivenThereIsAServiceRunningOn("http://localhost:51879"))
|
.And(x => GivenThereIsAServiceRunningOn("http://localhost:51611"))
|
||||||
.And(x => GivenOcelotIsRunning())
|
.And(x => GivenOcelotIsRunning())
|
||||||
.When(x => WhenIGetUrlOnTheApiGatewayMultipleTimesWithDifferentHeaderValues("/", 300))
|
.When(x => WhenIGetUrlOnTheApiGatewayMultipleTimesWithDifferentHeaderValues("/", 300))
|
||||||
.Then(x => ThenTheSameHeaderValuesAreReturnedByTheDownstreamService())
|
.Then(x => ThenTheSameHeaderValuesAreReturnedByTheDownstreamService())
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VersionPrefix>0.0.0-dev</VersionPrefix>
|
<VersionPrefix>0.0.0-dev</VersionPrefix>
|
||||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
<PreserveCompilationContext>true</PreserveCompilationContext>
|
<PreserveCompilationContext>true</PreserveCompilationContext>
|
||||||
<AssemblyName>Ocelot.ManualTest</AssemblyName>
|
<AssemblyName>Ocelot.ManualTest</AssemblyName>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
@ -40,6 +40,6 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" />
|
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="1.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -41,13 +41,13 @@ namespace Ocelot.UnitTests.Configuration
|
|||||||
_internalConfigCreator = new Mock<IInternalConfigurationCreator>();
|
_internalConfigCreator = new Mock<IInternalConfigurationCreator>();
|
||||||
_internalConfigCreator.Setup(x => x.Create(It.IsAny<FileConfiguration>())).ReturnsAsync(new OkResponse<IInternalConfiguration>(_internalConfig));
|
_internalConfigCreator.Setup(x => x.Create(It.IsAny<FileConfiguration>())).ReturnsAsync(new OkResponse<IInternalConfiguration>(_internalConfig));
|
||||||
_poller = new FileConfigurationPoller(_factory.Object, _repo.Object, _config.Object, _internalConfigRepo.Object, _internalConfigCreator.Object);
|
_poller = new FileConfigurationPoller(_factory.Object, _repo.Object, _config.Object, _internalConfigRepo.Object, _internalConfigCreator.Object);
|
||||||
_poller.StartAsync(new CancellationToken());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void should_start()
|
public void should_start()
|
||||||
{
|
{
|
||||||
this.Given(x => ThenTheSetterIsCalled(_fileConfig, 1))
|
this.Given(x => GivenPollerHasStarted())
|
||||||
|
.Given(x => ThenTheSetterIsCalled(_fileConfig, 1))
|
||||||
.BDDfy();
|
.BDDfy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,8 @@ namespace Ocelot.UnitTests.Configuration
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => WhenTheConfigIsChanged(newConfig, 0))
|
this.Given(x => GivenPollerHasStarted())
|
||||||
|
.Given(x => WhenTheConfigIsChanged(newConfig, 0))
|
||||||
.Then(x => ThenTheSetterIsCalledAtLeast(newConfig, 1))
|
.Then(x => ThenTheSetterIsCalledAtLeast(newConfig, 1))
|
||||||
.BDDfy();
|
.BDDfy();
|
||||||
}
|
}
|
||||||
@ -96,7 +97,8 @@ namespace Ocelot.UnitTests.Configuration
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => WhenTheConfigIsChanged(newConfig, 10))
|
this.Given(x => GivenPollerHasStarted())
|
||||||
|
.Given(x => WhenTheConfigIsChanged(newConfig, 10))
|
||||||
.Then(x => ThenTheSetterIsCalled(newConfig, 1))
|
.Then(x => ThenTheSetterIsCalled(newConfig, 1))
|
||||||
.BDDfy();
|
.BDDfy();
|
||||||
}
|
}
|
||||||
@ -121,11 +123,24 @@ namespace Ocelot.UnitTests.Configuration
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.Given(x => WhenProviderErrors())
|
this.Given(x => GivenPollerHasStarted())
|
||||||
|
.Given(x => WhenProviderErrors())
|
||||||
.Then(x => ThenTheSetterIsCalled(newConfig, 0))
|
.Then(x => ThenTheSetterIsCalled(newConfig, 0))
|
||||||
.BDDfy();
|
.BDDfy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void should_dispose_cleanly_without_starting()
|
||||||
|
{
|
||||||
|
this.When(x => WhenPollerIsDisposed())
|
||||||
|
.BDDfy();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GivenPollerHasStarted()
|
||||||
|
{
|
||||||
|
_poller.StartAsync(CancellationToken.None);
|
||||||
|
}
|
||||||
|
|
||||||
private void WhenProviderErrors()
|
private void WhenProviderErrors()
|
||||||
{
|
{
|
||||||
_repo
|
_repo
|
||||||
@ -141,6 +156,11 @@ namespace Ocelot.UnitTests.Configuration
|
|||||||
.ReturnsAsync(new OkResponse<FileConfiguration>(newConfig));
|
.ReturnsAsync(new OkResponse<FileConfiguration>(newConfig));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void WhenPollerIsDisposed()
|
||||||
|
{
|
||||||
|
_poller.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
private void ThenTheSetterIsCalled(FileConfiguration fileConfig, int times)
|
private void ThenTheSetterIsCalled(FileConfiguration fileConfig, int times)
|
||||||
{
|
{
|
||||||
var result = WaitFor(4000).Until(() =>
|
var result = WaitFor(4000).Until(() =>
|
||||||
|
@ -41,7 +41,7 @@ namespace Ocelot.UnitTests.Configuration
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var expectedOptions = new HttpHandlerOptions(false, false, false, true);
|
var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue);
|
||||||
|
|
||||||
this.Given(x => GivenTheFollowing(fileReRoute))
|
this.Given(x => GivenTheFollowing(fileReRoute))
|
||||||
.When(x => WhenICreateHttpHandlerOptions())
|
.When(x => WhenICreateHttpHandlerOptions())
|
||||||
@ -60,7 +60,7 @@ namespace Ocelot.UnitTests.Configuration
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var expectedOptions = new HttpHandlerOptions(false, false, true, true);
|
var expectedOptions = new HttpHandlerOptions(false, false, true, true, int.MaxValue);
|
||||||
|
|
||||||
this.Given(x => GivenTheFollowing(fileReRoute))
|
this.Given(x => GivenTheFollowing(fileReRoute))
|
||||||
.And(x => GivenARealTracer())
|
.And(x => GivenARealTracer())
|
||||||
@ -73,7 +73,7 @@ namespace Ocelot.UnitTests.Configuration
|
|||||||
public void should_create_options_with_useCookie_false_and_allowAutoRedirect_true_as_default()
|
public void should_create_options_with_useCookie_false_and_allowAutoRedirect_true_as_default()
|
||||||
{
|
{
|
||||||
var fileReRoute = new FileReRoute();
|
var fileReRoute = new FileReRoute();
|
||||||
var expectedOptions = new HttpHandlerOptions(false, false, false, true);
|
var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue);
|
||||||
|
|
||||||
this.Given(x => GivenTheFollowing(fileReRoute))
|
this.Given(x => GivenTheFollowing(fileReRoute))
|
||||||
.When(x => WhenICreateHttpHandlerOptions())
|
.When(x => WhenICreateHttpHandlerOptions())
|
||||||
@ -94,7 +94,7 @@ namespace Ocelot.UnitTests.Configuration
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var expectedOptions = new HttpHandlerOptions(false, false, false, true);
|
var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue);
|
||||||
|
|
||||||
this.Given(x => GivenTheFollowing(fileReRoute))
|
this.Given(x => GivenTheFollowing(fileReRoute))
|
||||||
.When(x => WhenICreateHttpHandlerOptions())
|
.When(x => WhenICreateHttpHandlerOptions())
|
||||||
@ -110,7 +110,7 @@ namespace Ocelot.UnitTests.Configuration
|
|||||||
HttpHandlerOptions = new FileHttpHandlerOptions()
|
HttpHandlerOptions = new FileHttpHandlerOptions()
|
||||||
};
|
};
|
||||||
|
|
||||||
var expectedOptions = new HttpHandlerOptions(false, false, false, true);
|
var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue);
|
||||||
|
|
||||||
this.Given(x => GivenTheFollowing(fileReRoute))
|
this.Given(x => GivenTheFollowing(fileReRoute))
|
||||||
.When(x => WhenICreateHttpHandlerOptions())
|
.When(x => WhenICreateHttpHandlerOptions())
|
||||||
@ -129,7 +129,64 @@ namespace Ocelot.UnitTests.Configuration
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var expectedOptions = new HttpHandlerOptions(false, false, false, false);
|
var expectedOptions = new HttpHandlerOptions(false, false, false, false, int.MaxValue);
|
||||||
|
|
||||||
|
this.Given(x => GivenTheFollowing(fileReRoute))
|
||||||
|
.When(x => WhenICreateHttpHandlerOptions())
|
||||||
|
.Then(x => ThenTheFollowingOptionsReturned(expectedOptions))
|
||||||
|
.BDDfy();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void should_create_options_with_specified_MaxConnectionsPerServer()
|
||||||
|
{
|
||||||
|
var fileReRoute = new FileReRoute
|
||||||
|
{
|
||||||
|
HttpHandlerOptions = new FileHttpHandlerOptions
|
||||||
|
{
|
||||||
|
MaxConnectionsPerServer = 10
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var expectedOptions = new HttpHandlerOptions(false, false, false, true, 10);
|
||||||
|
|
||||||
|
this.Given(x => GivenTheFollowing(fileReRoute))
|
||||||
|
.When(x => WhenICreateHttpHandlerOptions())
|
||||||
|
.Then(x => ThenTheFollowingOptionsReturned(expectedOptions))
|
||||||
|
.BDDfy();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void should_create_options_fixing_specified_MaxConnectionsPerServer_range()
|
||||||
|
{
|
||||||
|
var fileReRoute = new FileReRoute
|
||||||
|
{
|
||||||
|
HttpHandlerOptions = new FileHttpHandlerOptions
|
||||||
|
{
|
||||||
|
MaxConnectionsPerServer = -1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue);
|
||||||
|
|
||||||
|
this.Given(x => GivenTheFollowing(fileReRoute))
|
||||||
|
.When(x => WhenICreateHttpHandlerOptions())
|
||||||
|
.Then(x => ThenTheFollowingOptionsReturned(expectedOptions))
|
||||||
|
.BDDfy();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void should_create_options_fixing_specified_MaxConnectionsPerServer_range_when_zero()
|
||||||
|
{
|
||||||
|
var fileReRoute = new FileReRoute
|
||||||
|
{
|
||||||
|
HttpHandlerOptions = new FileHttpHandlerOptions
|
||||||
|
{
|
||||||
|
MaxConnectionsPerServer = 0
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var expectedOptions = new HttpHandlerOptions(false, false, false, true, int.MaxValue);
|
||||||
|
|
||||||
this.Given(x => GivenTheFollowing(fileReRoute))
|
this.Given(x => GivenTheFollowing(fileReRoute))
|
||||||
.When(x => WhenICreateHttpHandlerOptions())
|
.When(x => WhenICreateHttpHandlerOptions())
|
||||||
@ -154,6 +211,7 @@ namespace Ocelot.UnitTests.Configuration
|
|||||||
_httpHandlerOptions.UseCookieContainer.ShouldBe(expected.UseCookieContainer);
|
_httpHandlerOptions.UseCookieContainer.ShouldBe(expected.UseCookieContainer);
|
||||||
_httpHandlerOptions.UseTracing.ShouldBe(expected.UseTracing);
|
_httpHandlerOptions.UseTracing.ShouldBe(expected.UseTracing);
|
||||||
_httpHandlerOptions.UseProxy.ShouldBe(expected.UseProxy);
|
_httpHandlerOptions.UseProxy.ShouldBe(expected.UseProxy);
|
||||||
|
_httpHandlerOptions.MaxConnectionsPerServer.ShouldBe(expected.MaxConnectionsPerServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GivenARealTracer()
|
private void GivenARealTracer()
|
||||||
|
@ -50,7 +50,7 @@ namespace Ocelot.UnitTests.Configuration
|
|||||||
};
|
};
|
||||||
var expected = new RateLimitOptionsBuilder()
|
var expected = new RateLimitOptionsBuilder()
|
||||||
.WithClientIdHeader("ClientIdHeader")
|
.WithClientIdHeader("ClientIdHeader")
|
||||||
.WithClientWhiteList(fileReRoute.RateLimitOptions.ClientWhitelist)
|
.WithClientWhiteList(() => fileReRoute.RateLimitOptions.ClientWhitelist)
|
||||||
.WithDisableRateLimitHeaders(true)
|
.WithDisableRateLimitHeaders(true)
|
||||||
.WithEnableRateLimiting(true)
|
.WithEnableRateLimiting(true)
|
||||||
.WithHttpStatusCode(200)
|
.WithHttpStatusCode(200)
|
||||||
|
@ -1341,6 +1341,32 @@
|
|||||||
.BDDfy();
|
.BDDfy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void configuration_is_invalid_when_placeholder_is_used_twice_in_upstream_path_template()
|
||||||
|
{
|
||||||
|
this.Given(x => x.GivenAConfiguration(new FileConfiguration
|
||||||
|
{
|
||||||
|
ReRoutes = new List<FileReRoute>
|
||||||
|
{
|
||||||
|
new FileReRoute
|
||||||
|
{
|
||||||
|
DownstreamPathTemplate = "/bar/{everything}",
|
||||||
|
DownstreamScheme = "http",
|
||||||
|
DownstreamHostAndPorts = new List<FileHostAndPort>
|
||||||
|
{
|
||||||
|
new FileHostAndPort() { Host = "a.b.cd" },
|
||||||
|
},
|
||||||
|
UpstreamPathTemplate = "/foo/bar/{everything}/{everything}",
|
||||||
|
UpstreamHttpMethod = new List<string> { "Get" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
.When(x => x.WhenIValidateTheConfiguration())
|
||||||
|
.Then(x => x.ThenTheResultIsNotValid())
|
||||||
|
.And(x => x.ThenTheErrorMessageAtPositionIs(0, "reRoute /foo/bar/{everything}/{everything} has duplicated placeholder"))
|
||||||
|
.BDDfy();
|
||||||
|
}
|
||||||
|
|
||||||
private void GivenAConfiguration(FileConfiguration fileConfiguration)
|
private void GivenAConfiguration(FileConfiguration fileConfiguration)
|
||||||
{
|
{
|
||||||
_fileConfiguration = fileConfiguration;
|
_fileConfiguration = fileConfiguration;
|
||||||
|
@ -350,6 +350,36 @@
|
|||||||
.BDDfy();
|
.BDDfy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void should_not_replace_by_empty_scheme()
|
||||||
|
{
|
||||||
|
var downstreamReRoute = new DownstreamReRouteBuilder()
|
||||||
|
.WithDownstreamScheme("")
|
||||||
|
.WithServiceName("Ocelot/OcelotApp")
|
||||||
|
.WithUseServiceDiscovery(true)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var downstreamRoute = new DownstreamRoute(
|
||||||
|
new List<PlaceholderNameAndValue>(),
|
||||||
|
new ReRouteBuilder()
|
||||||
|
.WithDownstreamReRoute(downstreamReRoute)
|
||||||
|
.Build());
|
||||||
|
|
||||||
|
var config = new ServiceProviderConfigurationBuilder()
|
||||||
|
.WithType("ServiceFabric")
|
||||||
|
.WithHost("localhost")
|
||||||
|
.WithPort(19081)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
this.Given(x => x.GivenTheDownStreamRouteIs(downstreamRoute))
|
||||||
|
.And(x => GivenTheServiceProviderConfigIs(config))
|
||||||
|
.And(x => x.GivenTheDownstreamRequestUriIs("https://localhost:19081?PartitionKind=test&PartitionKey=1"))
|
||||||
|
.And(x => x.GivenTheUrlReplacerWillReturnSequence("/api/products/1", "Ocelot/OcelotApp"))
|
||||||
|
.When(x => x.WhenICallTheMiddleware())
|
||||||
|
.Then(x => x.ThenTheDownstreamRequestUriIs("https://localhost:19081/Ocelot/OcelotApp/api/products/1?PartitionKind=test&PartitionKey=1"))
|
||||||
|
.BDDfy();
|
||||||
|
}
|
||||||
|
|
||||||
private void GivenTheServiceProviderConfigIs(ServiceProviderConfiguration config)
|
private void GivenTheServiceProviderConfigIs(ServiceProviderConfiguration config)
|
||||||
{
|
{
|
||||||
var configuration = new InternalConfiguration(null, null, config, null, null, null, null, null);
|
var configuration = new InternalConfiguration(null, null, config, null, null, null, null, null);
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using Ocelot.Middleware;
|
using Ocelot.Middleware;
|
||||||
|
|
||||||
namespace Ocelot.UnitTests.LoadBalancer
|
namespace Ocelot.UnitTests.LoadBalancer
|
||||||
@ -108,6 +110,26 @@ namespace Ocelot.UnitTests.LoadBalancer
|
|||||||
.BDDfy();
|
.BDDfy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void should_set_scheme()
|
||||||
|
{
|
||||||
|
var downstreamRoute = new DownstreamReRouteBuilder()
|
||||||
|
.WithUpstreamHttpMethod(new List<string> { "Get" })
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var serviceProviderConfig = new ServiceProviderConfigurationBuilder()
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
this.Given(x => x.GivenTheDownStreamUrlIs("http://my.url/abc?q=123"))
|
||||||
|
.And(x => GivenTheConfigurationIs(serviceProviderConfig))
|
||||||
|
.And(x => x.GivenTheDownStreamRouteIs(downstreamRoute, new List<Ocelot.DownstreamRouteFinder.UrlMatcher.PlaceholderNameAndValue>()))
|
||||||
|
.And(x => x.GivenTheLoadBalancerHouseReturns())
|
||||||
|
.And(x => x.GivenTheLoadBalancerReturnsOk())
|
||||||
|
.When(x => x.WhenICallTheMiddleware())
|
||||||
|
.Then(x => x.ThenAnHostAndPortIsSetOnPipeline())
|
||||||
|
.BDDfy();
|
||||||
|
}
|
||||||
|
|
||||||
private void WhenICallTheMiddleware()
|
private void WhenICallTheMiddleware()
|
||||||
{
|
{
|
||||||
_middleware = new LoadBalancingMiddleware(_next, _loggerFactory.Object, _loadBalancerHouse.Object);
|
_middleware = new LoadBalancingMiddleware(_next, _loggerFactory.Object, _loadBalancerHouse.Object);
|
||||||
@ -135,6 +157,13 @@ namespace Ocelot.UnitTests.LoadBalancer
|
|||||||
.ReturnsAsync(_getHostAndPortError);
|
.ReturnsAsync(_getHostAndPortError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void GivenTheLoadBalancerReturnsOk()
|
||||||
|
{
|
||||||
|
_loadBalancer
|
||||||
|
.Setup(x => x.Lease(It.IsAny<DownstreamContext>()))
|
||||||
|
.ReturnsAsync(new OkResponse<ServiceHostAndPort>(new ServiceHostAndPort("abc", 123, "https")));
|
||||||
|
}
|
||||||
|
|
||||||
private void GivenTheLoadBalancerReturns()
|
private void GivenTheLoadBalancerReturns()
|
||||||
{
|
{
|
||||||
_hostAndPort = new ServiceHostAndPort("127.0.0.1", 80);
|
_hostAndPort = new ServiceHostAndPort("127.0.0.1", 80);
|
||||||
@ -186,6 +215,13 @@ namespace Ocelot.UnitTests.LoadBalancer
|
|||||||
_downstreamContext.Errors.ShouldBe(_getHostAndPortError.Errors);
|
_downstreamContext.Errors.ShouldBe(_getHostAndPortError.Errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ThenAnHostAndPortIsSetOnPipeline()
|
||||||
|
{
|
||||||
|
_downstreamContext.DownstreamRequest.Host.ShouldBeEquivalentTo("abc");
|
||||||
|
_downstreamContext.DownstreamRequest.Port.ShouldBeEquivalentTo(123);
|
||||||
|
_downstreamContext.DownstreamRequest.Scheme.ShouldBeEquivalentTo("https");
|
||||||
|
}
|
||||||
|
|
||||||
private void ThenTheDownstreamUrlIsReplacedWith(string expectedUri)
|
private void ThenTheDownstreamUrlIsReplacedWith(string expectedUri)
|
||||||
{
|
{
|
||||||
_downstreamContext.DownstreamRequest.ToHttpRequestMessage().RequestUri.OriginalString.ShouldBe(expectedUri);
|
_downstreamContext.DownstreamRequest.ToHttpRequestMessage().RequestUri.OriginalString.ShouldBe(expectedUri);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user