diff --git a/src/Ocelot.ApiGateway/.gitignore b/.gitignore similarity index 100% rename from src/Ocelot.ApiGateway/.gitignore rename to .gitignore diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 50f9b3d8..00000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "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/Ocelot.sln b/Ocelot.sln new file mode 100644 index 00000000..848e011d --- /dev/null +++ b/Ocelot.sln @@ -0,0 +1,50 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5CFB79B7-C9DC-45A4-9A75-625D92471702}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3FA7C349-DBE8-4904-A2CE-015B8869CE6C}" + ProjectSection(SolutionItems) = preProject + global.json = global.json + LICENSE.md = LICENSE.md + README.md = README.md + EndProjectSection +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ocelot", "src\Ocelot\Ocelot.xproj", "{AEC8FB40-B370-48A6-9B38-78E560041F01}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ocelot.Library", "src\Ocelot.Library\Ocelot.Library.xproj", "{D6DF4206-0DBA-41D8-884D-C3E08290FDBB}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{5B401523-36DA-4491-B73A-7590A26E420B}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Ocelot.UnitTests", "test\Ocelot.UnitTests\Ocelot.UnitTests.xproj", "{54E84F1A-E525-4443-96EC-039CBD50C263}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AEC8FB40-B370-48A6-9B38-78E560041F01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AEC8FB40-B370-48A6-9B38-78E560041F01}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AEC8FB40-B370-48A6-9B38-78E560041F01}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AEC8FB40-B370-48A6-9B38-78E560041F01}.Release|Any CPU.Build.0 = Release|Any CPU + {D6DF4206-0DBA-41D8-884D-C3E08290FDBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D6DF4206-0DBA-41D8-884D-C3E08290FDBB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D6DF4206-0DBA-41D8-884D-C3E08290FDBB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D6DF4206-0DBA-41D8-884D-C3E08290FDBB}.Release|Any CPU.Build.0 = Release|Any CPU + {54E84F1A-E525-4443-96EC-039CBD50C263}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {54E84F1A-E525-4443-96EC-039CBD50C263}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54E84F1A-E525-4443-96EC-039CBD50C263}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54E84F1A-E525-4443-96EC-039CBD50C263}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {AEC8FB40-B370-48A6-9B38-78E560041F01} = {5CFB79B7-C9DC-45A4-9A75-625D92471702} + {D6DF4206-0DBA-41D8-884D-C3E08290FDBB} = {5CFB79B7-C9DC-45A4-9A75-625D92471702} + {54E84F1A-E525-4443-96EC-039CBD50C263} = {5B401523-36DA-4491-B73A-7590A26E420B} + EndGlobalSection +EndGlobal diff --git a/global.json b/global.json new file mode 100644 index 00000000..0d315988 --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ + { + "projects": [ "src", "test" ], + "sdk": { + "version": "1.0.0-preview2-003121" + } +} diff --git a/src/Ocelot.ApiGateway/Dockerfile b/src/Ocelot.ApiGateway/Dockerfile deleted file mode 100644 index 5ea50452..00000000 --- a/src/Ocelot.ApiGateway/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -FROM microsoft/aspnet:1.0.0-rc1-update1 - -RUN printf "deb http://ftp.us.debian.org/debian jessie main\n" >> /etc/apt/sources.list -RUN apt-get -qq update && apt-get install -qqy sqlite3 libsqlite3-dev && rm -rf /var/lib/apt/lists/* - -COPY . /app -WORKDIR /app -RUN ["dnu", "restore"] - -EXPOSE 5000/tcp -ENTRYPOINT ["dnx", "-p", "project.json", "Microsoft.AspNet.Server.Kestrel", "--server.urls", "http://0.0.0.0:5000"] diff --git a/src/Ocelot.ApiGateway/project.json b/src/Ocelot.ApiGateway/project.json deleted file mode 100644 index 9e614198..00000000 --- a/src/Ocelot.ApiGateway/project.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "dependencies": { - "Microsoft.NETCore.App": { - "version": "1.0.0-rc2-3002702", - "type": "platform" - }, - "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final", - "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final", - "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final", - "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final", - "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final", - "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final", - "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", - "xunit": "2.1.0", - "dotnet-test-xunit": "1.0.0-rc2-final", - "Shouldly": "2.8.0" - }, - - "testRunner":"xunit", - - "tools": { - "Microsoft.AspNetCore.Server.IISIntegration.Tools": { - "version": "1.0.0-preview1-final", - "imports": "portable-net45+win8+dnxcore50" - } - }, - - "frameworks": { - "netcoreapp1.0": { - "imports": [ - "dotnet5.6", - "dnxcore50", - "portable-net45+win8" - ] - } - }, - - "buildOptions": { - "emitEntryPoint": true, - "preserveCompilationContext": true - }, - - "runtimeOptions": { - "gcServer": true - }, - - "publishOptions": { - "include": [ - "wwwroot", - "Views", - "appsettings.json", - "web.config" - ] - }, - - "scripts": { - "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] - }, - - "tooling": { - "defaultNamespace": "Ocelot.ApiGateway" - } -} diff --git a/src/Ocelot.ApiGateway/Infrastructure/Responses/Error.cs b/src/Ocelot.Library/Infrastructure/Responses/Error.cs similarity index 78% rename from src/Ocelot.ApiGateway/Infrastructure/Responses/Error.cs rename to src/Ocelot.Library/Infrastructure/Responses/Error.cs index e66a9bf8..57684854 100644 --- a/src/Ocelot.ApiGateway/Infrastructure/Responses/Error.cs +++ b/src/Ocelot.Library/Infrastructure/Responses/Error.cs @@ -1,4 +1,4 @@ -namespace Ocelot.ApiGateway.Infrastructure.Responses +namespace Ocelot.Library.Infrastructure.Responses { public abstract class Error { diff --git a/src/Ocelot.ApiGateway/Infrastructure/Responses/ErrorResponse.cs b/src/Ocelot.Library/Infrastructure/Responses/ErrorResponse.cs similarity index 60% rename from src/Ocelot.ApiGateway/Infrastructure/Responses/ErrorResponse.cs rename to src/Ocelot.Library/Infrastructure/Responses/ErrorResponse.cs index 884c4ac0..5233f358 100644 --- a/src/Ocelot.ApiGateway/Infrastructure/Responses/ErrorResponse.cs +++ b/src/Ocelot.Library/Infrastructure/Responses/ErrorResponse.cs @@ -1,7 +1,7 @@ -namespace Ocelot.ApiGateway.Infrastructure.Responses -{ - using System.Collections.Generic; +using System.Collections.Generic; +namespace Ocelot.Library.Infrastructure.Responses +{ public class ErrorResponse : Response { public ErrorResponse(List errors) : base(errors) diff --git a/src/Ocelot.ApiGateway/Infrastructure/Responses/ErrorResponseGeneric.cs b/src/Ocelot.Library/Infrastructure/Responses/ErrorResponseGeneric.cs similarity index 61% rename from src/Ocelot.ApiGateway/Infrastructure/Responses/ErrorResponseGeneric.cs rename to src/Ocelot.Library/Infrastructure/Responses/ErrorResponseGeneric.cs index cb1ddb05..95bda1b7 100644 --- a/src/Ocelot.ApiGateway/Infrastructure/Responses/ErrorResponseGeneric.cs +++ b/src/Ocelot.Library/Infrastructure/Responses/ErrorResponseGeneric.cs @@ -1,7 +1,7 @@ -namespace Ocelot.ApiGateway.Infrastructure.Responses -{ - using System.Collections.Generic; +using System.Collections.Generic; +namespace Ocelot.Library.Infrastructure.Responses +{ public class ErrorResponse : Response { public ErrorResponse(List errors) : base(errors) diff --git a/src/Ocelot.ApiGateway/Infrastructure/Responses/OkResponse.cs b/src/Ocelot.Library/Infrastructure/Responses/OkResponse.cs similarity index 65% rename from src/Ocelot.ApiGateway/Infrastructure/Responses/OkResponse.cs rename to src/Ocelot.Library/Infrastructure/Responses/OkResponse.cs index 1f02b6e5..0b71f0d0 100644 --- a/src/Ocelot.ApiGateway/Infrastructure/Responses/OkResponse.cs +++ b/src/Ocelot.Library/Infrastructure/Responses/OkResponse.cs @@ -1,4 +1,4 @@ -namespace Ocelot.ApiGateway.Infrastructure.Responses +namespace Ocelot.Library.Infrastructure.Responses { public class OkResponse : Response { diff --git a/src/Ocelot.ApiGateway/Infrastructure/Responses/OkResponseGeneric.cs b/src/Ocelot.Library/Infrastructure/Responses/OkResponseGeneric.cs similarity index 70% rename from src/Ocelot.ApiGateway/Infrastructure/Responses/OkResponseGeneric.cs rename to src/Ocelot.Library/Infrastructure/Responses/OkResponseGeneric.cs index 010a28a9..a18ac11f 100644 --- a/src/Ocelot.ApiGateway/Infrastructure/Responses/OkResponseGeneric.cs +++ b/src/Ocelot.Library/Infrastructure/Responses/OkResponseGeneric.cs @@ -1,4 +1,4 @@ -namespace Ocelot.ApiGateway.Infrastructure.Responses +namespace Ocelot.Library.Infrastructure.Responses { public class OkResponse : Response { diff --git a/src/Ocelot.ApiGateway/Infrastructure/Responses/Response.cs b/src/Ocelot.Library/Infrastructure/Responses/Response.cs similarity index 77% rename from src/Ocelot.ApiGateway/Infrastructure/Responses/Response.cs rename to src/Ocelot.Library/Infrastructure/Responses/Response.cs index 091d6f98..6651c0f7 100644 --- a/src/Ocelot.ApiGateway/Infrastructure/Responses/Response.cs +++ b/src/Ocelot.Library/Infrastructure/Responses/Response.cs @@ -1,7 +1,7 @@ -namespace Ocelot.ApiGateway.Infrastructure.Responses -{ - using System.Collections.Generic; +using System.Collections.Generic; +namespace Ocelot.Library.Infrastructure.Responses +{ public abstract class Response { protected Response() diff --git a/src/Ocelot.ApiGateway/Infrastructure/Responses/ResponseGeneric.cs b/src/Ocelot.Library/Infrastructure/Responses/ResponseGeneric.cs similarity index 75% rename from src/Ocelot.ApiGateway/Infrastructure/Responses/ResponseGeneric.cs rename to src/Ocelot.Library/Infrastructure/Responses/ResponseGeneric.cs index c78c8b6d..97e72e10 100644 --- a/src/Ocelot.ApiGateway/Infrastructure/Responses/ResponseGeneric.cs +++ b/src/Ocelot.Library/Infrastructure/Responses/ResponseGeneric.cs @@ -1,7 +1,7 @@ -namespace Ocelot.ApiGateway.Infrastructure.Responses -{ - using System.Collections.Generic; +using System.Collections.Generic; +namespace Ocelot.Library.Infrastructure.Responses +{ public abstract class Response : Response { protected Response(T data) diff --git a/src/Ocelot.ApiGateway/Infrastructure/Router/IRouterService.cs b/src/Ocelot.Library/Infrastructure/Router/IRouterService.cs similarity index 62% rename from src/Ocelot.ApiGateway/Infrastructure/Router/IRouterService.cs rename to src/Ocelot.Library/Infrastructure/Router/IRouterService.cs index aa68859b..61f7b48d 100644 --- a/src/Ocelot.ApiGateway/Infrastructure/Router/IRouterService.cs +++ b/src/Ocelot.Library/Infrastructure/Router/IRouterService.cs @@ -1,6 +1,6 @@ -using Ocelot.ApiGateway.Infrastructure.Responses; +using Ocelot.Library.Infrastructure.Responses; -namespace Ocelot.ApiGateway.Infrastructure.Router +namespace Ocelot.Library.Infrastructure.Router { public interface IRouterService { diff --git a/src/Ocelot.ApiGateway/Infrastructure/Router/InMemoryRouterService.cs b/src/Ocelot.Library/Infrastructure/Router/InMemoryRouterService.cs similarity index 88% rename from src/Ocelot.ApiGateway/Infrastructure/Router/InMemoryRouterService.cs rename to src/Ocelot.Library/Infrastructure/Router/InMemoryRouterService.cs index 4394e667..d3e73746 100644 --- a/src/Ocelot.ApiGateway/Infrastructure/Router/InMemoryRouterService.cs +++ b/src/Ocelot.Library/Infrastructure/Router/InMemoryRouterService.cs @@ -1,12 +1,12 @@ using System; using System.Collections.Generic; -using Ocelot.ApiGateway.Infrastructure.Responses; +using Ocelot.Library.Infrastructure.Responses; -namespace Ocelot.ApiGateway.Infrastructure.Router +namespace Ocelot.Library.Infrastructure.Router { public class InMemoryRouterService : IRouterService { - private Dictionary _routes; + private readonly Dictionary _routes; public InMemoryRouterService() { _routes = new Dictionary(); diff --git a/src/Ocelot.ApiGateway/Infrastructure/Router/Route.cs b/src/Ocelot.Library/Infrastructure/Router/Route.cs similarity index 85% rename from src/Ocelot.ApiGateway/Infrastructure/Router/Route.cs rename to src/Ocelot.Library/Infrastructure/Router/Route.cs index 0edae1ef..f76f6173 100644 --- a/src/Ocelot.ApiGateway/Infrastructure/Router/Route.cs +++ b/src/Ocelot.Library/Infrastructure/Router/Route.cs @@ -1,4 +1,4 @@ -namespace Ocelot.ApiGateway.Infrastructure.Router +namespace Ocelot.Library.Infrastructure.Router { public class Route { diff --git a/src/Ocelot.ApiGateway/Infrastructure/Router/RouteKeyAlreadyExists.cs b/src/Ocelot.Library/Infrastructure/Router/RouteKeyAlreadyExists.cs similarity index 62% rename from src/Ocelot.ApiGateway/Infrastructure/Router/RouteKeyAlreadyExists.cs rename to src/Ocelot.Library/Infrastructure/Router/RouteKeyAlreadyExists.cs index 0a89b302..1ae13795 100644 --- a/src/Ocelot.ApiGateway/Infrastructure/Router/RouteKeyAlreadyExists.cs +++ b/src/Ocelot.Library/Infrastructure/Router/RouteKeyAlreadyExists.cs @@ -1,6 +1,6 @@ -using Ocelot.ApiGateway.Infrastructure.Responses; +using Ocelot.Library.Infrastructure.Responses; -namespace Ocelot.ApiGateway.Infrastructure.Router +namespace Ocelot.Library.Infrastructure.Router { public class RouteKeyAlreadyExists : Error { diff --git a/src/Ocelot.ApiGateway/Infrastructure/Router/RouteKeyDoesNotExist.cs b/src/Ocelot.Library/Infrastructure/Router/RouteKeyDoesNotExist.cs similarity index 61% rename from src/Ocelot.ApiGateway/Infrastructure/Router/RouteKeyDoesNotExist.cs rename to src/Ocelot.Library/Infrastructure/Router/RouteKeyDoesNotExist.cs index 9b745f00..f38aea5e 100644 --- a/src/Ocelot.ApiGateway/Infrastructure/Router/RouteKeyDoesNotExist.cs +++ b/src/Ocelot.Library/Infrastructure/Router/RouteKeyDoesNotExist.cs @@ -1,6 +1,6 @@ -using Ocelot.ApiGateway.Infrastructure.Responses; +using Ocelot.Library.Infrastructure.Responses; -namespace Ocelot.ApiGateway.Infrastructure.Router +namespace Ocelot.Library.Infrastructure.Router { public class RouteKeyDoesNotExist : Error { diff --git a/src/Ocelot.ApiGateway/Middleware/ProxyExtensions.cs b/src/Ocelot.Library/Middleware/ProxyExtensions.cs similarity index 86% rename from src/Ocelot.ApiGateway/Middleware/ProxyExtensions.cs rename to src/Ocelot.Library/Middleware/ProxyExtensions.cs index 444afa20..83777448 100644 --- a/src/Ocelot.ApiGateway/Middleware/ProxyExtensions.cs +++ b/src/Ocelot.Library/Middleware/ProxyExtensions.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Builder; -namespace Ocelot.ApiGateway.Middleware +namespace Ocelot.Library.Middleware { public static class ProxyExtensions { diff --git a/src/Ocelot.ApiGateway/Middleware/ProxyMiddleware.cs b/src/Ocelot.Library/Middleware/ProxyMiddleware.cs similarity index 90% rename from src/Ocelot.ApiGateway/Middleware/ProxyMiddleware.cs rename to src/Ocelot.Library/Middleware/ProxyMiddleware.cs index a904a816..a8698273 100644 --- a/src/Ocelot.ApiGateway/Middleware/ProxyMiddleware.cs +++ b/src/Ocelot.Library/Middleware/ProxyMiddleware.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; -namespace Ocelot.ApiGateway.Middleware +namespace Ocelot.Library.Middleware { public class ProxyMiddleware { diff --git a/src/Ocelot.ApiGateway/Middleware/RequestLoggerExtensions.cs b/src/Ocelot.Library/Middleware/RequestLoggerExtensions.cs similarity index 87% rename from src/Ocelot.ApiGateway/Middleware/RequestLoggerExtensions.cs rename to src/Ocelot.Library/Middleware/RequestLoggerExtensions.cs index 24aa764a..0d1a0027 100644 --- a/src/Ocelot.ApiGateway/Middleware/RequestLoggerExtensions.cs +++ b/src/Ocelot.Library/Middleware/RequestLoggerExtensions.cs @@ -1,6 +1,6 @@ using Microsoft.AspNetCore.Builder; -namespace Ocelot.ApiGateway.Middleware +namespace Ocelot.Library.Middleware { public static class RequestLoggerExtensions { diff --git a/src/Ocelot.ApiGateway/Middleware/RequestLoggerMiddleware.cs b/src/Ocelot.Library/Middleware/RequestLoggerMiddleware.cs similarity index 94% rename from src/Ocelot.ApiGateway/Middleware/RequestLoggerMiddleware.cs rename to src/Ocelot.Library/Middleware/RequestLoggerMiddleware.cs index 5780bfdc..554433b2 100644 --- a/src/Ocelot.ApiGateway/Middleware/RequestLoggerMiddleware.cs +++ b/src/Ocelot.Library/Middleware/RequestLoggerMiddleware.cs @@ -2,7 +2,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; -namespace Ocelot.ApiGateway.Middleware +namespace Ocelot.Library.Middleware { public class RequestLoggerMiddleware { diff --git a/src/Ocelot.Library/Ocelot.Library.xproj b/src/Ocelot.Library/Ocelot.Library.xproj new file mode 100644 index 00000000..d5f127c2 --- /dev/null +++ b/src/Ocelot.Library/Ocelot.Library.xproj @@ -0,0 +1,21 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + d6df4206-0dba-41d8-884d-c3e08290fdbb + Ocelot.Library + .\obj + .\bin\ + v4.5 + + + + 2.0 + + + diff --git a/src/Ocelot.Library/Properties/AssemblyInfo.cs b/src/Ocelot.Library/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..cf59e825 --- /dev/null +++ b/src/Ocelot.Library/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ocelot.Library")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d6df4206-0dba-41d8-884d-c3e08290fdbb")] diff --git a/src/Ocelot.Library/project.json b/src/Ocelot.Library/project.json new file mode 100644 index 00000000..ca884c95 --- /dev/null +++ b/src/Ocelot.Library/project.json @@ -0,0 +1,30 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + }, + "Microsoft.AspNetCore.Mvc": "1.0.0", + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", + "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", + "Microsoft.Extensions.Configuration.Json": "1.0.0", + "Microsoft.Extensions.Logging": "1.0.0", + "Microsoft.Extensions.Logging.Console": "1.0.0", + "Microsoft.Extensions.Logging.Debug": "1.0.0", + "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", + "Microsoft.AspNetCore.Http": "1.0.0" + }, + + "frameworks": { + "netcoreapp1.0": { + "imports": [ + "dotnet5.6", + "portable-net45+win8" + ] + } + } +} diff --git a/src/Ocelot/Ocelot.xproj b/src/Ocelot/Ocelot.xproj new file mode 100644 index 00000000..86842479 --- /dev/null +++ b/src/Ocelot/Ocelot.xproj @@ -0,0 +1,19 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + aec8fb40-b370-48a6-9b38-78e560041f01 + Ocelot + .\obj + .\bin\ + v4.5.2 + + + 2.0 + + + diff --git a/src/Ocelot.ApiGateway/Program.cs b/src/Ocelot/Program.cs similarity index 79% rename from src/Ocelot.ApiGateway/Program.cs rename to src/Ocelot/Program.cs index b5404270..e8777ea7 100644 --- a/src/Ocelot.ApiGateway/Program.cs +++ b/src/Ocelot/Program.cs @@ -1,8 +1,12 @@ +using System; +using System.Collections.Generic; using System.IO; +using System.Linq; +using System.Threading.Tasks; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Builder; -namespace Ocelot.ApiGateway +namespace Ocelot { public class Program { diff --git a/src/Ocelot.ApiGateway/Properties/launchSettings.json b/src/Ocelot/Properties/launchSettings.json similarity index 77% rename from src/Ocelot.ApiGateway/Properties/launchSettings.json rename to src/Ocelot/Properties/launchSettings.json index 3f72d44b..7fc77fcd 100644 --- a/src/Ocelot.ApiGateway/Properties/launchSettings.json +++ b/src/Ocelot/Properties/launchSettings.json @@ -3,20 +3,20 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:55368/", + "applicationUrl": "http://localhost:1798/", "sslPort": 0 } }, "profiles": { "IIS Express": { - "commandName" : "IISExpress", + "commandName": "IISExpress", "launchBrowser": true, "launchUrl": "api/values", - "environmentVariables" : { + "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } }, - "Ocelot.ApiGateway": { + "Ocelot": { "commandName": "Project", "launchBrowser": true, "launchUrl": "http://localhost:5000/api/values", @@ -25,4 +25,4 @@ } } } -} +} \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/Startup.cs b/src/Ocelot/Startup.cs similarity index 82% rename from src/Ocelot.ApiGateway/Startup.cs rename to src/Ocelot/Startup.cs index c163c10b..990e0cd5 100644 --- a/src/Ocelot.ApiGateway/Startup.cs +++ b/src/Ocelot/Startup.cs @@ -1,14 +1,12 @@ -using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Http; 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 -{ +namespace Ocelot +{ public class Startup { public Startup(IHostingEnvironment env) @@ -20,30 +18,26 @@ namespace Ocelot.ApiGateway .AddEnvironmentVariables(); Configuration = builder.Build(); } - + public IConfigurationRoot Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddRouting(); + // Add framework services. + } - + // 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(); - - app.Run(async context => + + app.Run(async context => { await context.Response.WriteAsync("Hello from Tom"); }); } } } - \ No newline at end of file diff --git a/src/Ocelot.ApiGateway/appsettings.json b/src/Ocelot/appsettings.json old mode 100755 new mode 100644 similarity index 93% rename from src/Ocelot.ApiGateway/appsettings.json rename to src/Ocelot/appsettings.json index cb1818e7..fa8ce71a --- a/src/Ocelot.ApiGateway/appsettings.json +++ b/src/Ocelot/appsettings.json @@ -1,10 +1,10 @@ -{ - "Logging": { - "IncludeScopes": false, - "LogLevel": { - "Default": "Debug", - "System": "Information", - "Microsoft": "Information" - } - } -} +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/src/Ocelot/project.json b/src/Ocelot/project.json new file mode 100644 index 00000000..ba309f23 --- /dev/null +++ b/src/Ocelot/project.json @@ -0,0 +1,58 @@ +{ + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + }, + "Microsoft.AspNetCore.Mvc": "1.0.0", + "Microsoft.AspNetCore.Http": "1.0.0", + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", + "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", + "Microsoft.Extensions.Configuration.Json": "1.0.0", + "Microsoft.Extensions.Logging": "1.0.0", + "Microsoft.Extensions.Logging.Console": "1.0.0", + "Microsoft.Extensions.Logging.Debug": "1.0.0", + "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", + "Ocelot.Library": "1.0.0-*" + }, + + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final" + }, + + "frameworks": { + "netcoreapp1.0": { + "imports": [ + "dotnet5.6", + "portable-net45+win8" + ] + } + }, + + "buildOptions": { + "emitEntryPoint": true, + "preserveCompilationContext": true + }, + + "runtimeOptions": { + "configProperties": { + "System.GC.Server": true + } + }, + + "publishOptions": { + "include": [ + "wwwroot", + "Views", + "Areas/**/Views", + "appsettings.json", + "web.config" + ] + }, + + "scripts": { + "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] + } +} diff --git a/src/Ocelot.ApiGateway/web.config b/src/Ocelot/web.config similarity index 80% rename from src/Ocelot.ApiGateway/web.config rename to src/Ocelot/web.config index 68ab630e..dc0514fc 100644 --- a/src/Ocelot.ApiGateway/web.config +++ b/src/Ocelot/web.config @@ -1,14 +1,14 @@ - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/test/Ocelot.UnitTests/Ocelot.UnitTests.xproj b/test/Ocelot.UnitTests/Ocelot.UnitTests.xproj new file mode 100644 index 00000000..0936ae02 --- /dev/null +++ b/test/Ocelot.UnitTests/Ocelot.UnitTests.xproj @@ -0,0 +1,22 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 54e84f1a-e525-4443-96ec-039cbd50c263 + Ocelot.UnitTests + .\obj + .\bin\ + v4.5 + + + 2.0 + + + + + + \ No newline at end of file diff --git a/test/Ocelot.UnitTests/Properties/AssemblyInfo.cs b/test/Ocelot.UnitTests/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a2be759e --- /dev/null +++ b/test/Ocelot.UnitTests/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Ocelot.UnitTests")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("54e84f1a-e525-4443-96ec-039cbd50c263")] diff --git a/src/Ocelot.ApiGateway/Infrastructure/Router/RouterTests.cs b/test/Ocelot.UnitTests/RouterTests.cs similarity index 95% rename from src/Ocelot.ApiGateway/Infrastructure/Router/RouterTests.cs rename to test/Ocelot.UnitTests/RouterTests.cs index 4cf1e1b1..e9f32823 100644 --- a/src/Ocelot.ApiGateway/Infrastructure/Router/RouterTests.cs +++ b/test/Ocelot.UnitTests/RouterTests.cs @@ -1,9 +1,9 @@ -using System; -using Ocelot.ApiGateway.Infrastructure.Responses; +using Ocelot.Library.Infrastructure.Responses; +using Ocelot.Library.Infrastructure.Router; using Shouldly; using Xunit; -namespace Ocelot.ApiGateway.Infrastructure.Router +namespace Ocelot.UnitTests { public class RouterTests { @@ -45,7 +45,7 @@ namespace Ocelot.ApiGateway.Infrastructure.Router [Fact] public void should_return_error_response_if_key_doesnt_exist() - { + { GivenIWantToRouteRequestsToMyUpstreamApi("api"); WhenIRetrieveTheRouteByKey(); ThenTheKeyDoesNotExist(); @@ -54,7 +54,7 @@ namespace Ocelot.ApiGateway.Infrastructure.Router private void WhenITryToUseTheSameKey() { WhenIAddTheConfiguration(); - } + } private void ThenTheKeyHasAlreadyBeenUsed() { @@ -101,7 +101,7 @@ namespace Ocelot.ApiGateway.Infrastructure.Router private void WhenIAddTheConfiguration() { _response = _router.AddRoute(_apiKey, _upstreamApiUrl); - } + } private void ThenTheResponseIsSuccesful() { diff --git a/test/Ocelot.UnitTests/project.json b/test/Ocelot.UnitTests/project.json new file mode 100644 index 00000000..926c8e73 --- /dev/null +++ b/test/Ocelot.UnitTests/project.json @@ -0,0 +1,36 @@ +{ + "version": "1.0.0-*", + + "testRunner": "xunit", + + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.0.0", + "type": "platform" + }, + "Microsoft.AspNetCore.Mvc": "1.0.0", + "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0", + "Microsoft.AspNetCore.Server.Kestrel": "1.0.0", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0", + "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", + "Microsoft.Extensions.Configuration.Json": "1.0.0", + "Microsoft.Extensions.Logging": "1.0.0", + "Microsoft.Extensions.Logging.Console": "1.0.0", + "Microsoft.Extensions.Logging.Debug": "1.0.0", + "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", + "Microsoft.AspNetCore.Http": "1.0.0", + "Ocelot.Library": "1.0.0-*", + "xunit": "2.1.0", + "dotnet-test-xunit": "2.2.0-preview2-build1029", + "Shouldly": "2.8.0" + }, + + "frameworks": { + "netcoreapp1.0": { + "imports": [ + "dotnet5.6", + "portable-net45+win8" + ] + } + } +}