mirror of
				https://github.com/nsnail/Ocelot.git
				synced 2025-11-04 12:10:50 +08:00 
			
		
		
		
	
							
								
								
									
										22
									
								
								samples/OcelotEureka/ApiGateway/ApiGateway.csproj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								samples/OcelotEureka/ApiGateway/ApiGateway.csproj
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
<Project Sdk="Microsoft.NET.Sdk.Web">
 | 
			
		||||
 | 
			
		||||
  <PropertyGroup>
 | 
			
		||||
    <TargetFramework>netcoreapp2.0</TargetFramework>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <Folder Include="wwwroot\" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
  
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <None Update="ocelot.json;appsettings.json">
 | 
			
		||||
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
 | 
			
		||||
    </None>
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
  <ItemGroup>
 | 
			
		||||
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.6" />
 | 
			
		||||
    <PackageReference Include="Ocelot" Version="5.5.7" />
 | 
			
		||||
  </ItemGroup>
 | 
			
		||||
 | 
			
		||||
</Project>
 | 
			
		||||
							
								
								
									
										38
									
								
								samples/OcelotEureka/ApiGateway/Program.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								samples/OcelotEureka/ApiGateway/Program.cs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
			
		||||
namespace ApiGateway
 | 
			
		||||
{
 | 
			
		||||
    using Microsoft.AspNetCore;
 | 
			
		||||
    using Microsoft.AspNetCore.Hosting;
 | 
			
		||||
    using Microsoft.Extensions.Configuration;
 | 
			
		||||
    using Ocelot.DependencyInjection;
 | 
			
		||||
    using Ocelot.Middleware;
 | 
			
		||||
 | 
			
		||||
    public class Program
 | 
			
		||||
    {
 | 
			
		||||
        public static void Main(string[] args)
 | 
			
		||||
        {
 | 
			
		||||
            BuildWebHost(args).Run();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static IWebHost BuildWebHost(string[] args) =>
 | 
			
		||||
            WebHost.CreateDefaultBuilder(args)
 | 
			
		||||
                .UseUrls("http://localhost:5000")
 | 
			
		||||
                .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();
 | 
			
		||||
                })
 | 
			
		||||
                .Configure(a =>
 | 
			
		||||
                {
 | 
			
		||||
                    a.UseOcelot().Wait();
 | 
			
		||||
                })
 | 
			
		||||
                .Build();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,27 @@
 | 
			
		||||
{
 | 
			
		||||
  "iisSettings": {
 | 
			
		||||
    "windowsAuthentication": false,
 | 
			
		||||
    "anonymousAuthentication": true,
 | 
			
		||||
    "iisExpress": {
 | 
			
		||||
      "applicationUrl": "http://localhost:54060/",
 | 
			
		||||
      "sslPort": 0
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "profiles": {
 | 
			
		||||
    "IIS Express": {
 | 
			
		||||
      "commandName": "IISExpress",
 | 
			
		||||
      "launchBrowser": true,
 | 
			
		||||
      "environmentVariables": {
 | 
			
		||||
        "ASPNETCORE_ENVIRONMENT": "Development"
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    "ApiGateway": {
 | 
			
		||||
      "commandName": "Project",
 | 
			
		||||
      "launchBrowser": true,
 | 
			
		||||
      "environmentVariables": {
 | 
			
		||||
        "ASPNETCORE_ENVIRONMENT": "Development"
 | 
			
		||||
      },
 | 
			
		||||
      "applicationUrl": "http://localhost:54061/"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										26
									
								
								samples/OcelotEureka/ApiGateway/appsettings.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								samples/OcelotEureka/ApiGateway/appsettings.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
{
 | 
			
		||||
  "Logging": {
 | 
			
		||||
    "IncludeScopes": true,
 | 
			
		||||
    "LogLevel": {
 | 
			
		||||
      "Default": "Trace",
 | 
			
		||||
      "System": "Information",
 | 
			
		||||
      "Microsoft": "Information"
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "spring": {
 | 
			
		||||
    "application": { "name": "Ocelot-Gateway" },
 | 
			
		||||
    "cloud": {
 | 
			
		||||
      "config": {
 | 
			
		||||
        "uri": "http://localhost:5000",
 | 
			
		||||
        "validateCertificates": false
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  "eureka": {
 | 
			
		||||
    "client": {
 | 
			
		||||
      "serviceUrl": "http://localhost:8761/eureka/",
 | 
			
		||||
      "shouldRegisterWithEureka": false,
 | 
			
		||||
      "validateCertificates": false
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										23
									
								
								samples/OcelotEureka/ApiGateway/ocelot.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								samples/OcelotEureka/ApiGateway/ocelot.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
{
 | 
			
		||||
  "ReRoutes": [
 | 
			
		||||
    {
 | 
			
		||||
      "DownstreamPathTemplate": "/api/Category",
 | 
			
		||||
      "DownstreamScheme": "http",
 | 
			
		||||
      "UpstreamPathTemplate": "/Category",
 | 
			
		||||
      "UseServiceDiscovery": true,
 | 
			
		||||
      "ServiceName": "ncore-rat",
 | 
			
		||||
      "UpstreamHttpMethod": [ "Get" ],
 | 
			
		||||
      "QoSOptions": {
 | 
			
		||||
        "ExceptionsAllowedBeforeBreaking": 3,
 | 
			
		||||
        "DurationOfBreak": 10000,
 | 
			
		||||
        "TimeoutValue": 5000
 | 
			
		||||
      },
 | 
			
		||||
      "FileCacheOptions": { "TtlSeconds": 15 }
 | 
			
		||||
    }
 | 
			
		||||
  ],
 | 
			
		||||
  "GlobalConfiguration": {
 | 
			
		||||
    "RequestIdKey": "OcRequestId",
 | 
			
		||||
    "AdministrationPath": "/administration",
 | 
			
		||||
    "ServiceDiscoveryProvider": { "Type": "Eureka" }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user