Skip to content

Commit

Permalink
First step
Browse files Browse the repository at this point in the history
  • Loading branch information
Ray committed Apr 14, 2023
1 parent 36ad6e1 commit 96a3fd8
Show file tree
Hide file tree
Showing 499 changed files with 5,325 additions and 4,310 deletions.
6 changes: 3 additions & 3 deletions samples/AdministrationApi/AdministrationApi.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Ocelot" Version="17.0.1" />
<PackageReference Include="Ocelot.Administration" Version="17.0.1" />
<PackageReference Include="Ocelot" Version="18.0.0" />
<PackageReference Include="Ocelot.Administration" Version="18.0.0" />

</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions samples/AdministrationApi/Issue645.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"id": "0f60e7b3-e4f1-4458-bbc4-fc4809e86b2d",
"type": "text/javascript",
"exec": [
""
string.Empty
]
}
},
Expand All @@ -142,7 +142,7 @@
"id": "1279a2cf-b771-4a86-9dfa-302b240fac62",
"type": "text/javascript",
"exec": [
""
string.Empty
]
}
}
Expand Down
69 changes: 36 additions & 33 deletions samples/AdministrationApi/Program.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,48 @@
using Microsoft.AspNetCore.Hosting;
using System.IO;

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

using Ocelot.Administration;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using System.IO;

namespace AdministrationApi
{
public class Program
{
public static void Main(string[] args)
{
new WebHostBuilder()
.UseKestrel()
.UseUrls("http://localhost:5000")
.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()
.AddAdministration("/administration", "secret");
})
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConsole();
})
.UseIISIntegration()
.Configure(app =>
{
app.UseOcelot().Wait();
})
.Build()
.Run();
public static void Main(string[] args)
{
new WebHostBuilder()
.UseKestrel()
.UseUrls("http://localhost:5000")
.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()
.AddAdministration("/administration", "secret");
})
.ConfigureLogging((hostingContext, logging) =>
{
logging.AddConsole();
})
.UseIISIntegration()
.Configure(app =>
{
app.UseOcelot().Wait();
})
.Build()
.Run();
}
}
}
}
4 changes: 2 additions & 2 deletions samples/OcelotBasic/OcelotBasic.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ocelot" Version="17.0.1" />
<PackageReference Include="ocelot" Version="18.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions samples/OcelotBasic/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.IO;

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;

Expand All @@ -23,7 +23,8 @@ public static void Main(string[] args)
.AddJsonFile("ocelot.json")
.AddEnvironmentVariables();
})
.ConfigureServices(s => {
.ConfigureServices(s =>
{
s.AddOcelot();
})
.ConfigureLogging((hostingContext, logging) =>
Expand Down
8 changes: 4 additions & 4 deletions samples/OcelotEureka/ApiGateway/ApiGateway.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand All @@ -15,9 +15,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Ocelot" Version="17.0.1" />
<PackageReference Include="Ocelot.Provider.Eureka" Version="17.0.1" />
<PackageReference Include="Ocelot.Provider.Polly" Version="17.0.1" />
<PackageReference Include="Ocelot" Version="18.0.0" />
<PackageReference Include="Ocelot.Provider.Eureka" Version="18.0.0" />
<PackageReference Include="Ocelot.Provider.Polly" Version="18.0.0" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions samples/OcelotEureka/ApiGateway/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace ApiGateway
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;

using Ocelot.DependencyInjection;
using Ocelot.Middleware;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;

using Microsoft.AspNetCore.Mvc;

namespace DownstreamService.Controllers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions samples/OcelotEureka/DownstreamService/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;

using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;

Expand Down
9 changes: 2 additions & 7 deletions samples/OcelotEureka/DownstreamService/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;

namespace DownstreamService
{
using Microsoft.Extensions.Hosting;

using Steeltoe.Discovery.Client;

public class Startup
Expand Down
6 changes: 3 additions & 3 deletions samples/OcelotGraphQL/OcelotGraphQL.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Update="ocelot.json;appsettings.json">
Expand All @@ -11,7 +11,7 @@
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Ocelot" Version="17.0.1" />
<PackageReference Include="GraphQL" Version="4.7.1" />
<PackageReference Include="Ocelot" Version="18.0.0" />
<PackageReference Include="GraphQL" Version="4.8.0" />
</ItemGroup>
</Project>
45 changes: 22 additions & 23 deletions samples/OcelotGraphQL/Program.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore;

using GraphQL;
using GraphQL.Types;

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Ocelot.Middleware;

using Ocelot.DependencyInjection;
using GraphQL.Types;
using GraphQL;
using Ocelot.Requester;
using Ocelot.Responses;
using System.Net.Http;
using System.Net;
using Microsoft.Extensions.DependencyInjection;
using System.Threading;
using Ocelot.Middleware;

namespace OcelotGraphQL
{
Expand All @@ -28,7 +27,7 @@ public class Hero

public class Query
{
private readonly List<Hero> _heroes = new List<Hero>
private readonly List<Hero> _heroes = new()
{
new Hero { Id = 1, Name = "R2-D2" },
new Hero { Id = 2, Name = "Batman" },
Expand All @@ -45,35 +44,35 @@ public Hero GetHero(int id)

public class GraphQlDelegatingHandler : DelegatingHandler
{
//private readonly ISchema _schema;
private readonly IDocumentExecuter _executer;
//private readonly ISchema _schema;
private readonly IDocumentExecuter _executer;
private readonly IDocumentWriter _writer;

public GraphQlDelegatingHandler(IDocumentExecuter executer, IDocumentWriter writer)
{
_executer = executer;
_executer = executer;
_writer = writer;
}

protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
//try get query from body, could check http method :)
var query = await request.Content.ReadAsStringAsync();
var query = await request.Content.ReadAsStringAsync(cancellationToken);

//if not body try query string, dont hack like this in real world..
if (query.Length == 0)
{
var decoded = WebUtility.UrlDecode(request.RequestUri.Query);
query = decoded.Replace("?query=", "");
query = decoded.Replace("?query=", string.Empty);
}


var result = await _executer.ExecuteAsync(_ =>
{
_.Query = query;
});

});

var responseBody = await _writer.WriteToStringAsync(result);


//maybe check for errors and headers etc in real world?
var response = new HttpResponseMessage(HttpStatusCode.OK)
{
Expand Down
8 changes: 4 additions & 4 deletions samples/OcelotKube/ApiGateway/ApiGateway.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
<PackageReference Include="Ocelot" Version="17.0.1" />
<PackageReference Include="Ocelot.Provider.Kubernetes" Version="17.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Ocelot" Version="18.0.0" />
<PackageReference Include="Ocelot.Provider.Kubernetes" Version="18.0.0" />
</ItemGroup>

</Project>
3 changes: 0 additions & 3 deletions samples/OcelotKube/ApiGateway/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.Provider.Kubernetes;

namespace ApiGateway
{
Expand Down
1 change: 1 addition & 0 deletions samples/OcelotKube/ApiGateway/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.Provider.Kubernetes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;

using Microsoft.AspNetCore.Mvc;

namespace DownstreamService.Controllers
Expand All @@ -14,7 +12,7 @@ public class ValuesController : ControllerBase
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return new string[] { "value1", "value2" };
return new[] { "value1", "value2" };
}

// GET api/values/5
Expand Down
Loading

0 comments on commit 96a3fd8

Please sign in to comment.