From 3777e8c0c82c92acde7ab826438b94d0e5a4bd74 Mon Sep 17 00:00:00 2001 From: Tom Gardham-Pallister Date: Sat, 2 Jul 2016 16:09:54 +0100 Subject: [PATCH] added some router thing and removed loads of crap --- .vscode/launch.json | 49 ++++ src/Ocelot.ApiGateway/AddRouteHandler.cs | 19 -- .../Infrastructure/Responses/Error.cs | 12 + .../Infrastructure/Responses/ErrorResponse.cs | 11 + .../Responses/ErrorResponseGeneric.cs | 11 + .../Infrastructure/Responses/OkResponse.cs | 9 + .../Responses/OkResponseGeneric.cs | 9 + .../Infrastructure/Responses/Response.cs | 19 ++ .../Responses/ResponseGeneric.cs | 18 ++ .../Infrastructure/Router/IRouterService.cs | 10 + .../Router/InMemoryRouterService.cs | 41 +++ .../Infrastructure/Router/Route.cs | 14 ++ .../Router/RouteKeyAlreadyExists.cs | 12 + .../Router/RouteKeyDoesNotExist.cs | 12 + .../Infrastructure/Router/RouterTests.cs | 111 +++++++++ .../Middleware/ProxyExtensions.cs | 12 + .../Middleware/ProxyMiddleware.cs | 20 ++ .../Middleware/RequestLoggerExtensions.cs | 12 + .../Middleware/RequestLoggerMiddleware.cs | 25 ++ src/Ocelot.ApiGateway/Routers.cs | 24 -- src/Ocelot.ApiGateway/Startup.cs | 21 +- src/Ocelot.ApiGateway/project.json | 6 +- src/Ocelot.Library/.gitignore | 234 ------------------ src/Ocelot.Library/RouterMiddleware.cs | 16 -- src/Ocelot.Library/project.json | 17 -- test/Ocelot.UnitTests/.gitignore | 234 ------------------ test/Ocelot.UnitTests/RouterMiddlwareTests.cs | 16 -- test/Ocelot.UnitTests/project.json | 21 -- 28 files changed, 425 insertions(+), 590 deletions(-) create mode 100644 .vscode/launch.json delete mode 100644 src/Ocelot.ApiGateway/AddRouteHandler.cs create mode 100644 src/Ocelot.ApiGateway/Infrastructure/Responses/Error.cs create mode 100644 src/Ocelot.ApiGateway/Infrastructure/Responses/ErrorResponse.cs create mode 100644 src/Ocelot.ApiGateway/Infrastructure/Responses/ErrorResponseGeneric.cs create mode 100644 src/Ocelot.ApiGateway/Infrastructure/Responses/OkResponse.cs create mode 100644 src/Ocelot.ApiGateway/Infrastructure/Responses/OkResponseGeneric.cs create mode 100644 src/Ocelot.ApiGateway/Infrastructure/Responses/Response.cs create mode 100644 src/Ocelot.ApiGateway/Infrastructure/Responses/ResponseGeneric.cs create mode 100644 src/Ocelot.ApiGateway/Infrastructure/Router/IRouterService.cs create mode 100644 src/Ocelot.ApiGateway/Infrastructure/Router/InMemoryRouterService.cs create mode 100644 src/Ocelot.ApiGateway/Infrastructure/Router/Route.cs create mode 100644 src/Ocelot.ApiGateway/Infrastructure/Router/RouteKeyAlreadyExists.cs create mode 100644 src/Ocelot.ApiGateway/Infrastructure/Router/RouteKeyDoesNotExist.cs create mode 100644 src/Ocelot.ApiGateway/Infrastructure/Router/RouterTests.cs create mode 100644 src/Ocelot.ApiGateway/Middleware/ProxyExtensions.cs create mode 100644 src/Ocelot.ApiGateway/Middleware/ProxyMiddleware.cs create mode 100644 src/Ocelot.ApiGateway/Middleware/RequestLoggerExtensions.cs create mode 100644 src/Ocelot.ApiGateway/Middleware/RequestLoggerMiddleware.cs delete mode 100644 src/Ocelot.ApiGateway/Routers.cs delete mode 100644 src/Ocelot.Library/.gitignore delete mode 100644 src/Ocelot.Library/RouterMiddleware.cs delete mode 100644 src/Ocelot.Library/project.json delete mode 100644 test/Ocelot.UnitTests/.gitignore delete mode 100644 test/Ocelot.UnitTests/RouterMiddlwareTests.cs delete mode 100644 test/Ocelot.UnitTests/project.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..50f9b3d8 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,49 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceRoot}/bin/Debug//", + "args": [], + "cwd": "${workspaceRoot}", + "stopAtEntry": false, + "externalConsole": false + }, + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceRoot}/bin/Debug//", + "args": [], + "cwd": "${workspaceRoot}", + "stopAtEntry": false, + "launchBrowser": { + "enabled": true, + "args": "${auto-detect-url}", + "windows": { + "command": "cmd.exe", + "args": "/C start ${auto-detect-url}" + }, + "osx": { + "command": "open" + }, + "linux": { + "command": "xdg-open" + } + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": 0 + } + ] +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/AddRouteHandler.cs b/src/Ocelot.ApiGateway/AddRouteHandler.cs deleted file mode 100644 index baaa05a4..00000000 --- a/src/Ocelot.ApiGateway/AddRouteHandler.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Routing; -using Microsoft.Extensions.DependencyInjection; - -namespace Ocelot.ApiGateway -{ - public static class HelloExtensions - { - public static IRouteBuilder AddRouter(this IRouteBuilder routeBuilder, - IApplicationBuilder app) - { - routeBuilder.Routes.Add(new Route(new Router(), - "{*url}", - app.ApplicationServices.GetService())); - - return routeBuilder; - } - } -} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Infrastructure/Responses/Error.cs b/src/Ocelot.ApiGateway/Infrastructure/Responses/Error.cs new file mode 100644 index 00000000..e66a9bf8 --- /dev/null +++ b/src/Ocelot.ApiGateway/Infrastructure/Responses/Error.cs @@ -0,0 +1,12 @@ +namespace Ocelot.ApiGateway.Infrastructure.Responses +{ + public abstract class Error + { + public Error(string message) + { + Message = message; + } + + public string Message { get; private set; } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Infrastructure/Responses/ErrorResponse.cs b/src/Ocelot.ApiGateway/Infrastructure/Responses/ErrorResponse.cs new file mode 100644 index 00000000..884c4ac0 --- /dev/null +++ b/src/Ocelot.ApiGateway/Infrastructure/Responses/ErrorResponse.cs @@ -0,0 +1,11 @@ +namespace Ocelot.ApiGateway.Infrastructure.Responses +{ + using System.Collections.Generic; + + public class ErrorResponse : Response + { + public ErrorResponse(List errors) : base(errors) + { + } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Infrastructure/Responses/ErrorResponseGeneric.cs b/src/Ocelot.ApiGateway/Infrastructure/Responses/ErrorResponseGeneric.cs new file mode 100644 index 00000000..cb1ddb05 --- /dev/null +++ b/src/Ocelot.ApiGateway/Infrastructure/Responses/ErrorResponseGeneric.cs @@ -0,0 +1,11 @@ +namespace Ocelot.ApiGateway.Infrastructure.Responses +{ + using System.Collections.Generic; + + public class ErrorResponse : Response + { + public ErrorResponse(List errors) : base(errors) + { + } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Infrastructure/Responses/OkResponse.cs b/src/Ocelot.ApiGateway/Infrastructure/Responses/OkResponse.cs new file mode 100644 index 00000000..1f02b6e5 --- /dev/null +++ b/src/Ocelot.ApiGateway/Infrastructure/Responses/OkResponse.cs @@ -0,0 +1,9 @@ +namespace Ocelot.ApiGateway.Infrastructure.Responses +{ + public class OkResponse : Response + { + public OkResponse() + { + } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Infrastructure/Responses/OkResponseGeneric.cs b/src/Ocelot.ApiGateway/Infrastructure/Responses/OkResponseGeneric.cs new file mode 100644 index 00000000..010a28a9 --- /dev/null +++ b/src/Ocelot.ApiGateway/Infrastructure/Responses/OkResponseGeneric.cs @@ -0,0 +1,9 @@ +namespace Ocelot.ApiGateway.Infrastructure.Responses +{ + public class OkResponse : Response + { + public OkResponse(T data) : base(data) + { + } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Infrastructure/Responses/Response.cs b/src/Ocelot.ApiGateway/Infrastructure/Responses/Response.cs new file mode 100644 index 00000000..091d6f98 --- /dev/null +++ b/src/Ocelot.ApiGateway/Infrastructure/Responses/Response.cs @@ -0,0 +1,19 @@ +namespace Ocelot.ApiGateway.Infrastructure.Responses +{ + using System.Collections.Generic; + + public abstract class Response + { + protected Response() + { + Errors = new List(); + } + + protected Response(List errors) + { + Errors = errors ?? new List(); + } + + public List Errors { get; private set; } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Infrastructure/Responses/ResponseGeneric.cs b/src/Ocelot.ApiGateway/Infrastructure/Responses/ResponseGeneric.cs new file mode 100644 index 00000000..c78c8b6d --- /dev/null +++ b/src/Ocelot.ApiGateway/Infrastructure/Responses/ResponseGeneric.cs @@ -0,0 +1,18 @@ +namespace Ocelot.ApiGateway.Infrastructure.Responses +{ + using System.Collections.Generic; + + public abstract class Response : Response + { + protected Response(T data) + { + Data = data; + } + + protected Response(List errors) : base(errors) + { + } + + public T Data { get; private set; } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Infrastructure/Router/IRouterService.cs b/src/Ocelot.ApiGateway/Infrastructure/Router/IRouterService.cs new file mode 100644 index 00000000..aa68859b --- /dev/null +++ b/src/Ocelot.ApiGateway/Infrastructure/Router/IRouterService.cs @@ -0,0 +1,10 @@ +using Ocelot.ApiGateway.Infrastructure.Responses; + +namespace Ocelot.ApiGateway.Infrastructure.Router +{ + public interface IRouterService + { + Response AddRoute(string apiKey, string upstreamApiBaseUrl); + Response GetRoute(string apiKey); + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Infrastructure/Router/InMemoryRouterService.cs b/src/Ocelot.ApiGateway/Infrastructure/Router/InMemoryRouterService.cs new file mode 100644 index 00000000..4394e667 --- /dev/null +++ b/src/Ocelot.ApiGateway/Infrastructure/Router/InMemoryRouterService.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using Ocelot.ApiGateway.Infrastructure.Responses; + +namespace Ocelot.ApiGateway.Infrastructure.Router +{ + public class InMemoryRouterService : IRouterService + { + private Dictionary _routes; + public InMemoryRouterService() + { + _routes = new Dictionary(); + } + public Response AddRoute(string apiKey, string upstreamApiBaseUrl) + { + if(_routes.ContainsKey(apiKey)) + { + return new ErrorResponse(new List(){new RouteKeyAlreadyExists("This key has already been used")}); + } + + _routes.Add(apiKey, upstreamApiBaseUrl); + + return new OkResponse(); + } + + public Response GetRoute(string apiKey) + { + Console.WriteLine("looking for {0}", apiKey); + string upstreamApiBaseUrl = null; + + if(_routes.TryGetValue(apiKey, out upstreamApiBaseUrl)) + { + return new OkResponse(new Route(apiKey, upstreamApiBaseUrl)); + } + + Console.WriteLine("Couldnt find it"); + + return new ErrorResponse(new List(){new RouteKeyDoesNotExist("This key does not exist")}); + } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Infrastructure/Router/Route.cs b/src/Ocelot.ApiGateway/Infrastructure/Router/Route.cs new file mode 100644 index 00000000..0edae1ef --- /dev/null +++ b/src/Ocelot.ApiGateway/Infrastructure/Router/Route.cs @@ -0,0 +1,14 @@ +namespace Ocelot.ApiGateway.Infrastructure.Router +{ + public class Route + { + public Route(string apiKey, string upstreamRoute) + { + ApiKey = apiKey; + UpstreamRoute = upstreamRoute; + } + + public string ApiKey {get;private set;} + public string UpstreamRoute {get;private set;} + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Infrastructure/Router/RouteKeyAlreadyExists.cs b/src/Ocelot.ApiGateway/Infrastructure/Router/RouteKeyAlreadyExists.cs new file mode 100644 index 00000000..0a89b302 --- /dev/null +++ b/src/Ocelot.ApiGateway/Infrastructure/Router/RouteKeyAlreadyExists.cs @@ -0,0 +1,12 @@ +using Ocelot.ApiGateway.Infrastructure.Responses; + +namespace Ocelot.ApiGateway.Infrastructure.Router +{ + public class RouteKeyAlreadyExists : Error + { + public RouteKeyAlreadyExists(string message) + : base(message) + { + } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Infrastructure/Router/RouteKeyDoesNotExist.cs b/src/Ocelot.ApiGateway/Infrastructure/Router/RouteKeyDoesNotExist.cs new file mode 100644 index 00000000..9b745f00 --- /dev/null +++ b/src/Ocelot.ApiGateway/Infrastructure/Router/RouteKeyDoesNotExist.cs @@ -0,0 +1,12 @@ +using Ocelot.ApiGateway.Infrastructure.Responses; + +namespace Ocelot.ApiGateway.Infrastructure.Router +{ + public class RouteKeyDoesNotExist : Error + { + public RouteKeyDoesNotExist(string message) + : base(message) + { + } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Infrastructure/Router/RouterTests.cs b/src/Ocelot.ApiGateway/Infrastructure/Router/RouterTests.cs new file mode 100644 index 00000000..4cf1e1b1 --- /dev/null +++ b/src/Ocelot.ApiGateway/Infrastructure/Router/RouterTests.cs @@ -0,0 +1,111 @@ +using System; +using Ocelot.ApiGateway.Infrastructure.Responses; +using Shouldly; +using Xunit; + +namespace Ocelot.ApiGateway.Infrastructure.Router +{ + public class RouterTests + { + private string _upstreamApiUrl; + private string _apiKey; + private IRouterService _router; + private Response _response; + private Response _getRouteResponse; + + public RouterTests() + { + _router = new InMemoryRouterService(); + } + + [Fact] + public void can_add_route() + { + GivenIHaveAnUpstreamApi("http://www.someapi.com/api1"); + GivenIWantToRouteRequestsToMyUpstreamApi("api"); + WhenIAddTheConfiguration(); + ThenTheResponseIsSuccesful(); + } + + [Fact] + public void can_get_route_by_key() + { + GivenIHaveSetUpAnApiKeyAndUpstreamUrl("api2", "http://www.someapi.com/api2"); + WhenIRetrieveTheRouteByKey(); + ThenTheRouteIsReturned(); + } + + [Fact] + public void should_return_error_response_when_key_already_used() + { + GivenIHaveSetUpAnApiKeyAndUpstreamUrl("api2", "http://www.someapi.com/api2"); + WhenITryToUseTheSameKey(); + ThenTheKeyHasAlreadyBeenUsed(); + } + + [Fact] + public void should_return_error_response_if_key_doesnt_exist() + { + GivenIWantToRouteRequestsToMyUpstreamApi("api"); + WhenIRetrieveTheRouteByKey(); + ThenTheKeyDoesNotExist(); + } + + private void WhenITryToUseTheSameKey() + { + WhenIAddTheConfiguration(); + } + + private void ThenTheKeyHasAlreadyBeenUsed() + { + _response.ShouldNotBeNull(); + _response.ShouldBeOfType(); + _response.Errors[0].Message.ShouldBe("This key has already been used"); + } + + private void ThenTheKeyDoesNotExist() + { + _getRouteResponse.ShouldNotBeNull(); + _getRouteResponse.ShouldBeOfType>(); + _getRouteResponse.Errors[0].Message.ShouldBe("This key does not exist"); + } + + private void WhenIRetrieveTheRouteByKey() + { + _getRouteResponse = _router.GetRoute(_apiKey); + } + + private void ThenTheRouteIsReturned() + { + _getRouteResponse.Data.ApiKey.ShouldBe(_apiKey); + _getRouteResponse.Data.UpstreamRoute.ShouldBe(_upstreamApiUrl); + } + + private void GivenIHaveSetUpAnApiKeyAndUpstreamUrl(string apiKey, string upstreamUrl) + { + GivenIHaveAnUpstreamApi(upstreamUrl); + GivenIWantToRouteRequestsToMyUpstreamApi(apiKey); + WhenIAddTheConfiguration(); + } + + private void GivenIHaveAnUpstreamApi(string upstreamApiUrl) + { + _upstreamApiUrl = upstreamApiUrl; + } + + private void GivenIWantToRouteRequestsToMyUpstreamApi(string apiKey) + { + _apiKey = apiKey; + } + + private void WhenIAddTheConfiguration() + { + _response = _router.AddRoute(_apiKey, _upstreamApiUrl); + } + + private void ThenTheResponseIsSuccesful() + { + _response.ShouldBeOfType(); + } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Middleware/ProxyExtensions.cs b/src/Ocelot.ApiGateway/Middleware/ProxyExtensions.cs new file mode 100644 index 00000000..444afa20 --- /dev/null +++ b/src/Ocelot.ApiGateway/Middleware/ProxyExtensions.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Builder; + +namespace Ocelot.ApiGateway.Middleware +{ + public static class ProxyExtensions + { + public static IApplicationBuilder UseProxy(this IApplicationBuilder builder) + { + return builder.UseMiddleware(); + } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Middleware/ProxyMiddleware.cs b/src/Ocelot.ApiGateway/Middleware/ProxyMiddleware.cs new file mode 100644 index 00000000..a904a816 --- /dev/null +++ b/src/Ocelot.ApiGateway/Middleware/ProxyMiddleware.cs @@ -0,0 +1,20 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; + +namespace Ocelot.ApiGateway.Middleware +{ + public class ProxyMiddleware + { + private readonly RequestDelegate _next; + + public ProxyMiddleware(RequestDelegate next) + { + _next = next; + } + + public async Task Invoke(HttpContext context) + { + await _next.Invoke(context); + } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Middleware/RequestLoggerExtensions.cs b/src/Ocelot.ApiGateway/Middleware/RequestLoggerExtensions.cs new file mode 100644 index 00000000..24aa764a --- /dev/null +++ b/src/Ocelot.ApiGateway/Middleware/RequestLoggerExtensions.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Builder; + +namespace Ocelot.ApiGateway.Middleware +{ + public static class RequestLoggerExtensions + { + public static IApplicationBuilder UseRequestLogger(this IApplicationBuilder builder) + { + return builder.UseMiddleware(); + } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Middleware/RequestLoggerMiddleware.cs b/src/Ocelot.ApiGateway/Middleware/RequestLoggerMiddleware.cs new file mode 100644 index 00000000..5780bfdc --- /dev/null +++ b/src/Ocelot.ApiGateway/Middleware/RequestLoggerMiddleware.cs @@ -0,0 +1,25 @@ +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Logging; + +namespace Ocelot.ApiGateway.Middleware +{ + public class RequestLoggerMiddleware + { + private readonly RequestDelegate _next; + private readonly ILogger _logger; + + public RequestLoggerMiddleware(RequestDelegate next, ILoggerFactory loggerFactory) + { + _next = next; + _logger = loggerFactory.CreateLogger(); + } + + public async Task Invoke(HttpContext context) + { + _logger.LogInformation("Handling request: " + context.Request.Path); + await _next.Invoke(context); + _logger.LogInformation("Finished handling request."); + } + } +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Routers.cs b/src/Ocelot.ApiGateway/Routers.cs deleted file mode 100644 index af8881bc..00000000 --- a/src/Ocelot.ApiGateway/Routers.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Threading.Tasks; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Routing; - -namespace Ocelot.ApiGateway -{ - public class Router : IRouter - { - public Task RouteAsync(RouteContext context) - { - context.Handler = async c => - { - await c.Response.WriteAsync($"Hi, Tom!"); - }; - - return Task.FromResult(0); - } - - public VirtualPathData GetVirtualPath(VirtualPathContext context) - { - return null; - } - } -} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Startup.cs b/src/Ocelot.ApiGateway/Startup.cs index c3c49020..c163c10b 100644 --- a/src/Ocelot.ApiGateway/Startup.cs +++ b/src/Ocelot.ApiGateway/Startup.cs @@ -4,9 +4,11 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.AspNetCore.Routing; +using Ocelot.ApiGateway.Middleware; +using Microsoft.AspNetCore.Http; namespace Ocelot.ApiGateway -{ +{ public class Startup { public Startup(IHostingEnvironment env) @@ -26,19 +28,22 @@ namespace Ocelot.ApiGateway { services.AddRouting(); } - + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); + + app.UseRequestLogger(); + app.UseProxy(); loggerFactory.AddDebug(); - - var routeBuilder = new RouteBuilder(app); - - routeBuilder.AddRouter(app); - - app.UseRouter(routeBuilder.Build()); + + app.Run(async context => + { + await context.Response.WriteAsync("Hello from Tom"); + }); } } } + \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/project.json b/src/Ocelot.ApiGateway/project.json index 05f7e266..9e614198 100644 --- a/src/Ocelot.ApiGateway/project.json +++ b/src/Ocelot.ApiGateway/project.json @@ -13,8 +13,12 @@ "Microsoft.Extensions.Logging": "1.0.0-rc2-final", "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final", "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final", - "Microsoft.AspNetCore.Routing": "1.0.0-rc2-final" + "xunit": "2.1.0", + "dotnet-test-xunit": "1.0.0-rc2-final", + "Shouldly": "2.8.0" }, + + "testRunner":"xunit", "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": { diff --git a/src/Ocelot.Library/.gitignore b/src/Ocelot.Library/.gitignore deleted file mode 100644 index 0ca27f04..00000000 --- a/src/Ocelot.Library/.gitignore +++ /dev/null @@ -1,234 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -build/ -bld/ -[Bb]in/ -[Oo]bj/ - -# Visual Studio 2015 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# DNX -project.lock.json -artifacts/ - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Microsoft Azure ApplicationInsights config file -ApplicationInsights.config - -# Windows Store app package directory -AppPackages/ -BundleArtifacts/ - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -node_modules/ -orleans.codegen.cs - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe - -# FAKE - F# Make -.fake/ diff --git a/src/Ocelot.Library/RouterMiddleware.cs b/src/Ocelot.Library/RouterMiddleware.cs deleted file mode 100644 index d4474325..00000000 --- a/src/Ocelot.Library/RouterMiddleware.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Ocelot.Library -{ - // This project can output the Class library as a NuGet Package. - // To enable this option, right-click on the project and select the Properties menu item. In the Build tab select "Produce outputs on build". - public class RouterMiddleware - { - public RouterMiddleware() - { - } - } -} diff --git a/src/Ocelot.Library/project.json b/src/Ocelot.Library/project.json deleted file mode 100644 index b72a5c6a..00000000 --- a/src/Ocelot.Library/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version": "1.0.0-*", - - "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24027" - }, - - "frameworks": { - "netstandard1.5": { - "imports": "dnxcore50" - } - }, - - "tooling": { - "defaultNamespace": "Ocelot.Library" - } -} diff --git a/test/Ocelot.UnitTests/.gitignore b/test/Ocelot.UnitTests/.gitignore deleted file mode 100644 index 0ca27f04..00000000 --- a/test/Ocelot.UnitTests/.gitignore +++ /dev/null @@ -1,234 +0,0 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -build/ -bld/ -[Bb]in/ -[Oo]bj/ - -# Visual Studio 2015 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# DNX -project.lock.json -artifacts/ - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Microsoft Azure ApplicationInsights config file -ApplicationInsights.config - -# Windows Store app package directory -AppPackages/ -BundleArtifacts/ - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -node_modules/ -orleans.codegen.cs - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe - -# FAKE - F# Make -.fake/ diff --git a/test/Ocelot.UnitTests/RouterMiddlwareTests.cs b/test/Ocelot.UnitTests/RouterMiddlwareTests.cs deleted file mode 100644 index 42fca0cb..00000000 --- a/test/Ocelot.UnitTests/RouterMiddlwareTests.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Ocelot.UnitTests -{ - // This project can output the Class library as a NuGet Package. - // To enable this option, right-click on the project and select the Properties menu item. In the Build tab select "Produce outputs on build". - public class RouterMiddlwareTests - { - public RouterMiddlwareTests() - { - } - } -} diff --git a/test/Ocelot.UnitTests/project.json b/test/Ocelot.UnitTests/project.json deleted file mode 100644 index ae4974e0..00000000 --- a/test/Ocelot.UnitTests/project.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "version": "1.0.0-*", - - "dependencies": { - "NETStandard.Library": "1.5.0-rc2-24027", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final", - "Microsoft.AspNetCore.Routing": "1.0.0-rc2-final", - "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final", - "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final" - }, - - "frameworks": { - "netstandard1.5": { - "imports": "dnxcore50" - } - }, - - "tooling": { - "defaultNamespace": "Ocelot.UnitTests" - } -}