Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,736 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/Server/AspNetClassic.Voyager/AspNetClassic.Voyager.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net461</TargetFramework> | ||
<AssemblyName>HotChocolate.AspNetClassic.Voyager</AssemblyName> | ||
<RootNamespace>HotChocolate.AspNetClassic.Voyager</RootNamespace> | ||
<PackageId>HotChocolate.AspNetClassic.Voyager</PackageId> | ||
<Description>Contains a GraphQL Voyager for ASP.net classic that can be used with the Hot Chocolate GraphQL server.</Description> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<DebugType>Full</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DefineConstants>TRACE;DEBUG;ASPNETCLASSIC</DefineConstants> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<DebugType>pdbonly</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DefineConstants>TRACE;ASPNETCLASSIC</DefineConstants> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="..\AspNetCore.Voyager\**\*.css;..\AspNetCore.Voyager\**\*.html;..\AspNetCore.Voyager\**\*.js;..\AspNetCore.Voyager\**\*.png" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Include="..\AspNetCore.Voyager\**\*.css;..\AspNetCore.Voyager\**\*.html;..\AspNetCore.Voyager\**\*.js;..\AspNetCore.Voyager\**\*.png" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Owin" Version="4.0.0" /> | ||
<PackageReference Include="Microsoft.Owin.StaticFiles" Version="4.0.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Core\Core\Core.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="..\AspNetCore.Voyager\**\*.cs" Exclude="..\AspNetCore.Voyager\bin\**\*.cs;..\AspNetCore.Voyager\obj\**\*.cs" /> | ||
</ItemGroup> | ||
|
||
</Project> |
150 changes: 150 additions & 0 deletions
150
src/Server/AspNetCore.Voyager/ApplicationBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
using System; | ||
|
||
#if ASPNETCLASSIC | ||
using HotChocolate.AspNetClassic.Voyager; | ||
using Microsoft.Owin; | ||
using Microsoft.Owin.FileSystems; | ||
using Microsoft.Owin.StaticFiles; | ||
using Microsoft.Owin.StaticFiles.ContentTypes; | ||
using Owin; | ||
using IApplicationBuilder = Owin.IAppBuilder; | ||
#else | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.StaticFiles; | ||
using Microsoft.Extensions.FileProviders; | ||
#endif | ||
|
||
#if ASPNETCLASSIC | ||
namespace HotChocolate.AspNetClassic.Voyager | ||
#else | ||
namespace HotChocolate.AspNetCore.Voyager | ||
#endif | ||
{ | ||
public static class ApplicationBuilderExtensions | ||
{ | ||
#if ASPNETCLASSIC | ||
private const string _resourcesNamespace = | ||
"HotChocolate.AspNetClassic.Voyager.Resources"; | ||
#else | ||
private const string _resourcesNamespace = | ||
"HotChocolate.AspNetCore.Voyager.Resources"; | ||
#endif | ||
|
||
public static IApplicationBuilder UseVoyager( | ||
this IApplicationBuilder applicationBuilder) | ||
{ | ||
return applicationBuilder.UseVoyager(new VoyagerOptions()); | ||
} | ||
|
||
public static IApplicationBuilder UseVoyager( | ||
this IApplicationBuilder applicationBuilder, | ||
PathString queryPath) | ||
{ | ||
return applicationBuilder.UseVoyager(new VoyagerOptions | ||
{ | ||
QueryPath = queryPath, | ||
Path = queryPath + new PathString("/voyager") | ||
}); | ||
} | ||
|
||
public static IApplicationBuilder UseVoyager( | ||
this IApplicationBuilder applicationBuilder, | ||
PathString queryPath, | ||
PathString uiPath) | ||
{ | ||
return applicationBuilder.UseVoyager(new VoyagerOptions | ||
{ | ||
QueryPath = queryPath, | ||
Path = uiPath | ||
}); | ||
} | ||
|
||
public static IApplicationBuilder UseVoyager( | ||
this IApplicationBuilder applicationBuilder, | ||
VoyagerOptions options) | ||
{ | ||
if (options == null) | ||
{ | ||
throw new ArgumentNullException(nameof(options)); | ||
} | ||
|
||
return applicationBuilder | ||
.UseVoyagerSettingsMiddleware(options) | ||
.UseVoyagerFileServer(options.Path); | ||
} | ||
|
||
private static IApplicationBuilder UseVoyagerSettingsMiddleware( | ||
this IApplicationBuilder applicationBuilder, | ||
VoyagerOptions options) | ||
{ | ||
return applicationBuilder.Map( | ||
options.Path.Add(new PathString("/settings.js")), | ||
#if ASPNETCLASSIC | ||
app => app.Use<SettingsMiddleware>(options)); | ||
#else | ||
app => app.UseMiddleware<SettingsMiddleware>(options)); | ||
#endif | ||
} | ||
|
||
#if ASPNETCLASSIC | ||
private static IApplicationBuilder UseVoyagerFileServer( | ||
this IApplicationBuilder applicationBuilder, | ||
PathString route) | ||
{ | ||
var fileServerOptions = new FileServerOptions | ||
{ | ||
RequestPath = route, | ||
FileSystem = CreateFileSystem(), | ||
EnableDefaultFiles = true, | ||
StaticFileOptions = | ||
{ | ||
ContentTypeProvider = | ||
new FileExtensionContentTypeProvider() | ||
} | ||
}; | ||
|
||
return applicationBuilder.UseFileServer(fileServerOptions); | ||
} | ||
#else | ||
private static IApplicationBuilder UseVoyagerFileServer( | ||
this IApplicationBuilder applicationBuilder, | ||
string path) | ||
{ | ||
var fileServerOptions = new FileServerOptions | ||
{ | ||
RequestPath = path, | ||
FileProvider = CreateFileProvider(), | ||
EnableDefaultFiles = true, | ||
StaticFileOptions = | ||
{ | ||
ContentTypeProvider = | ||
new FileExtensionContentTypeProvider() | ||
} | ||
}; | ||
|
||
return applicationBuilder.UseFileServer(fileServerOptions); | ||
} | ||
#endif | ||
|
||
#if ASPNETCLASSIC | ||
private static IFileSystem CreateFileSystem() | ||
{ | ||
Type type = typeof(ApplicationBuilderExtensions); | ||
|
||
return new EmbeddedResourceFileSystem( | ||
type.Assembly, | ||
_resourcesNamespace); | ||
} | ||
#else | ||
private static IFileProvider CreateFileProvider() | ||
{ | ||
Type type = typeof(ApplicationBuilderExtensions); | ||
|
||
return new EmbeddedFileProvider( | ||
type.Assembly, | ||
_resourcesNamespace); | ||
} | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<AssemblyName>HotChocolate.AspNetCore.Voyager</AssemblyName> | ||
<RootNamespace>HotChocolate.AspNetCore.Voyager</RootNamespace> | ||
<PackageId>HotChocolate.AspNetCore.Voyager</PackageId> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<DebugType>Full</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<DebugType>pdbonly</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" /> | ||
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="2.1.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="Resources\*.*" /> | ||
<EmbeddedResource Include="Resources\*.*" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System.Threading; | ||
|
||
#if ASPNETCLASSIC | ||
using Microsoft.Owin; | ||
using HttpContext = Microsoft.Owin.IOwinContext; | ||
#else | ||
using Microsoft.AspNetCore.Http; | ||
#endif | ||
|
||
#if ASPNETCLASSIC | ||
namespace HotChocolate.AspNetClassic.Voyager | ||
#else | ||
namespace HotChocolate.AspNetCore.Voyager | ||
#endif | ||
{ | ||
internal static class HttpContextExtensions | ||
{ | ||
public static CancellationToken GetCancellationToken( | ||
this HttpContext context) | ||
{ | ||
#if ASPNETCLASSIC | ||
return context.Request.CallCancelled; | ||
#else | ||
return context.RequestAborted; | ||
#endif | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/Server/AspNetCore.Voyager/Resources/es6-promise.auto.min.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.