Skip to content

Return HTML Content #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Created by .ignore support plugin (hsz.mobi)
### VisualStudio template
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
Expand All @@ -26,11 +24,14 @@ bld/
[Oo]bj/
[Ll]og/

# Visual Studio 2015 cache/options directory
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

# Visual Studio 2017 auto generated files
Generated\ Files/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
Expand All @@ -51,16 +52,21 @@ BenchmarkDotNet.Artifacts/
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json

# StyleCop
StyleCopReport.xml

# Files built by Visual Studio
*_i.c
*_p.c
*_i.h
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
Expand Down Expand Up @@ -214,6 +220,10 @@ ClientBin/
*.publishsettings
orleans.codegen.cs

# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk

# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
Expand All @@ -228,6 +238,8 @@ _UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak

# SQL Server files
*.mdf
Expand All @@ -238,6 +250,7 @@ UpgradeLog*.htm
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser

# Microsoft Fakes
FakesAssemblies/
Expand All @@ -249,9 +262,6 @@ FakesAssemblies/
.ntvs_analysis.dat
node_modules/

# Typescript v1 declaration files
typings/

# Visual Studio 6 build log
*.plg

Expand Down Expand Up @@ -306,4 +316,17 @@ __pycache__/
# OpenCover UI analysis results
OpenCover/

# Azure Stream Analytics local run output
ASALocalRun/

# MSBuild Binary and Structured Log
*.binlog

# NVidia Nsight GPU debugger configuration file
*.nvuser

# MFractors (Xamarin productivity tool) working folder
.mfractor/

# Local History for Visual Studio
.localhistory/
87 changes: 87 additions & 0 deletions Carter.HtmlNegotiator.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Carter.HtmlNegotiator", "src\Carter.HtmlNegotiator.csproj", "{0DBC4DD8-CC92-4C36-A6CA-ABEE717458CA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dependencies", "dependencies", "{7B61769A-8EB6-4752-AF80-7F15558B2C76}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Carter", "Carter", "{C6E6F2C4-A88C-4E9D-9183-D3EB572423DE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Carter", "dependencies\Carter\src\Carter.csproj", "{E5B3E5AF-CA11-42EA-A9D0-72147B457AA3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Carter.HtmlNegotiator.Sample", "sample\Carter.HtmlNegotiator.Sample.csproj", "{C0D65C1D-698E-4601-98D2-D0BA4E5C0F47}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{520CAA77-64DE-43BF-B173-6E1A8F3A40B9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlNegotiator.Tests", "tests\HtmlNegotiator.Tests\HtmlNegotiator.Tests.csproj", "{A398FEB7-7F6E-4C98-9DA8-A35BE8D76C53}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0DBC4DD8-CC92-4C36-A6CA-ABEE717458CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0DBC4DD8-CC92-4C36-A6CA-ABEE717458CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0DBC4DD8-CC92-4C36-A6CA-ABEE717458CA}.Debug|x64.ActiveCfg = Debug|Any CPU
{0DBC4DD8-CC92-4C36-A6CA-ABEE717458CA}.Debug|x64.Build.0 = Debug|Any CPU
{0DBC4DD8-CC92-4C36-A6CA-ABEE717458CA}.Debug|x86.ActiveCfg = Debug|Any CPU
{0DBC4DD8-CC92-4C36-A6CA-ABEE717458CA}.Debug|x86.Build.0 = Debug|Any CPU
{0DBC4DD8-CC92-4C36-A6CA-ABEE717458CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0DBC4DD8-CC92-4C36-A6CA-ABEE717458CA}.Release|Any CPU.Build.0 = Release|Any CPU
{0DBC4DD8-CC92-4C36-A6CA-ABEE717458CA}.Release|x64.ActiveCfg = Release|Any CPU
{0DBC4DD8-CC92-4C36-A6CA-ABEE717458CA}.Release|x64.Build.0 = Release|Any CPU
{0DBC4DD8-CC92-4C36-A6CA-ABEE717458CA}.Release|x86.ActiveCfg = Release|Any CPU
{0DBC4DD8-CC92-4C36-A6CA-ABEE717458CA}.Release|x86.Build.0 = Release|Any CPU
{E5B3E5AF-CA11-42EA-A9D0-72147B457AA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5B3E5AF-CA11-42EA-A9D0-72147B457AA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5B3E5AF-CA11-42EA-A9D0-72147B457AA3}.Debug|x64.ActiveCfg = Debug|Any CPU
{E5B3E5AF-CA11-42EA-A9D0-72147B457AA3}.Debug|x64.Build.0 = Debug|Any CPU
{E5B3E5AF-CA11-42EA-A9D0-72147B457AA3}.Debug|x86.ActiveCfg = Debug|Any CPU
{E5B3E5AF-CA11-42EA-A9D0-72147B457AA3}.Debug|x86.Build.0 = Debug|Any CPU
{E5B3E5AF-CA11-42EA-A9D0-72147B457AA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E5B3E5AF-CA11-42EA-A9D0-72147B457AA3}.Release|Any CPU.Build.0 = Release|Any CPU
{E5B3E5AF-CA11-42EA-A9D0-72147B457AA3}.Release|x64.ActiveCfg = Release|Any CPU
{E5B3E5AF-CA11-42EA-A9D0-72147B457AA3}.Release|x64.Build.0 = Release|Any CPU
{E5B3E5AF-CA11-42EA-A9D0-72147B457AA3}.Release|x86.ActiveCfg = Release|Any CPU
{E5B3E5AF-CA11-42EA-A9D0-72147B457AA3}.Release|x86.Build.0 = Release|Any CPU
{C0D65C1D-698E-4601-98D2-D0BA4E5C0F47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0D65C1D-698E-4601-98D2-D0BA4E5C0F47}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C0D65C1D-698E-4601-98D2-D0BA4E5C0F47}.Debug|x64.ActiveCfg = Debug|Any CPU
{C0D65C1D-698E-4601-98D2-D0BA4E5C0F47}.Debug|x64.Build.0 = Debug|Any CPU
{C0D65C1D-698E-4601-98D2-D0BA4E5C0F47}.Debug|x86.ActiveCfg = Debug|Any CPU
{C0D65C1D-698E-4601-98D2-D0BA4E5C0F47}.Debug|x86.Build.0 = Debug|Any CPU
{C0D65C1D-698E-4601-98D2-D0BA4E5C0F47}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C0D65C1D-698E-4601-98D2-D0BA4E5C0F47}.Release|Any CPU.Build.0 = Release|Any CPU
{C0D65C1D-698E-4601-98D2-D0BA4E5C0F47}.Release|x64.ActiveCfg = Release|Any CPU
{C0D65C1D-698E-4601-98D2-D0BA4E5C0F47}.Release|x64.Build.0 = Release|Any CPU
{C0D65C1D-698E-4601-98D2-D0BA4E5C0F47}.Release|x86.ActiveCfg = Release|Any CPU
{C0D65C1D-698E-4601-98D2-D0BA4E5C0F47}.Release|x86.Build.0 = Release|Any CPU
{A398FEB7-7F6E-4C98-9DA8-A35BE8D76C53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A398FEB7-7F6E-4C98-9DA8-A35BE8D76C53}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A398FEB7-7F6E-4C98-9DA8-A35BE8D76C53}.Debug|x64.ActiveCfg = Debug|Any CPU
{A398FEB7-7F6E-4C98-9DA8-A35BE8D76C53}.Debug|x64.Build.0 = Debug|Any CPU
{A398FEB7-7F6E-4C98-9DA8-A35BE8D76C53}.Debug|x86.ActiveCfg = Debug|Any CPU
{A398FEB7-7F6E-4C98-9DA8-A35BE8D76C53}.Debug|x86.Build.0 = Debug|Any CPU
{A398FEB7-7F6E-4C98-9DA8-A35BE8D76C53}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A398FEB7-7F6E-4C98-9DA8-A35BE8D76C53}.Release|Any CPU.Build.0 = Release|Any CPU
{A398FEB7-7F6E-4C98-9DA8-A35BE8D76C53}.Release|x64.ActiveCfg = Release|Any CPU
{A398FEB7-7F6E-4C98-9DA8-A35BE8D76C53}.Release|x64.Build.0 = Release|Any CPU
{A398FEB7-7F6E-4C98-9DA8-A35BE8D76C53}.Release|x86.ActiveCfg = Release|Any CPU
{A398FEB7-7F6E-4C98-9DA8-A35BE8D76C53}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{C6E6F2C4-A88C-4E9D-9183-D3EB572423DE} = {7B61769A-8EB6-4752-AF80-7F15558B2C76}
{E5B3E5AF-CA11-42EA-A9D0-72147B457AA3} = {C6E6F2C4-A88C-4E9D-9183-D3EB572423DE}
{A398FEB7-7F6E-4C98-9DA8-A35BE8D76C53} = {520CAA77-64DE-43BF-B173-6E1A8F3A40B9}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion dependencies/Carter
20 changes: 20 additions & 0 deletions sample/Carter.HtmlNegotiator.Sample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AssemblyName>Carter.HtmlNegotiator.Sample</AssemblyName>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.1.0" />
<PackageReference Include="Carter" Version="3.7.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\dependencies\Carter\src\Carter.csproj" />
<ProjectReference Include="..\src\Carter.HtmlNegotiator.csproj" />
</ItemGroup>
</Project>
16 changes: 16 additions & 0 deletions sample/Features/MyFeature/MyFeatureModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Carter.HtmlNegotiator.Sample.Features.MyFeature
{
using ViewModels;

public class MyFeatureModule : CarterModule
{
public MyFeatureModule() : base("/myfeature")
{
Get("/",
async (req, res, routeData) =>
{
await res.AsHtml("index", new MyViewModel{Title = "Hello World!", Message = "Hello from a Custom View Location"});
});
}
}
}
9 changes: 9 additions & 0 deletions sample/Features/MyFeature/views/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html lang="en">
<head>
<title>{{title}}</title>
</head>
<body>
<h1>{{message}}</h1>
</body>
</html>
16 changes: 16 additions & 0 deletions sample/Modules/AnotherModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Carter.HtmlNegotiator.Sample.Modules
{
using ViewModels;

public class AnotherModule : CarterModule
{
public AnotherModule() : base("/another")
{
Get("/",
async (req, res, routeData) =>
{
await res.AsHtml("index", new MyViewModel{Title = "Hello World!", Message = "Hello from Another Module!"});
});
}
}
}
23 changes: 23 additions & 0 deletions sample/Modules/HomeModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace Carter.HtmlNegotiator.Sample.Modules
{
using Carter;
using ViewModels;

public class HomeModule : CarterModule
{
public HomeModule()
{
Get("/",
async (req, res, routeData) =>
{
await res.AsHtml("index",new MyViewModel{Title = "Hello World!", Message = "Hello from Carter.HtmlNegotiator!"});
});

Get("/custom",
async (req, res, routeData) =>
{
await res.AsHtml("myView", new MyViewModel{Title = "Custom View!", Message = "Hello from a custom view name!"});
});
}
}
}
19 changes: 19 additions & 0 deletions sample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace Carter.HtmlNegotiator.Sample
{
using System.IO;
using Microsoft.AspNetCore.Hosting;

public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseKestrel()
.UseStartup<Startup>()
.Build();

host.Run();
}
}
}
25 changes: 25 additions & 0 deletions sample/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Carter.HtmlNegotiator.Sample
{
using Carter;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddHtmlNegotiator(with =>
with.ViewLocation(ctx => $"features/{ctx.ModuleName}/views/{ctx.ViewName}"));
services.AddCarter();
}

public void Configure(IApplicationBuilder app, ILoggerFactory logging)
{
logging.AddConsole();
logging.AddDebug();

app.UseCarter();
}
}
}
8 changes: 8 additions & 0 deletions sample/ViewModels/MyViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Carter.HtmlNegotiator.Sample.ViewModels
{
public class MyViewModel
{
public string Title { get; set; }
public string Message { get; set; }
}
}
Binary file added sample/Views/.DS_Store
Binary file not shown.
9 changes: 9 additions & 0 deletions sample/Views/Another/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html lang="en">
<head>
<title>{{title}}</title>
</head>
<body>
<h1>{{message}}</h1>
</body>
</html>
9 changes: 9 additions & 0 deletions sample/Views/Home/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html lang="en">
<head>
<title>{{title}}</title>
</head>
<body>
<h1>{{message}}</h1>
</body>
</html>
9 changes: 9 additions & 0 deletions sample/Views/Home/myView.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html lang="en">
<head>
<title>{{title}}</title>
</head>
<body>
<h1>{{message}}</h1>
</body>
</html>
9 changes: 9 additions & 0 deletions src/AmbiguousViewsException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Carter.HtmlNegotiator
{
using System;

public class AmbiguousViewsException : Exception
{
public AmbiguousViewsException(string message) : base(message) {}
}
}
Loading