Initial Commit
ln.build build job pending
ln.build build job pending
commit
453ec7234b
|
@ -0,0 +1,41 @@
|
||||||
|
# Autosave files
|
||||||
|
*~
|
||||||
|
|
||||||
|
# build
|
||||||
|
[Oo]bj/
|
||||||
|
[Bb]in/
|
||||||
|
packages/
|
||||||
|
TestResults/
|
||||||
|
|
||||||
|
# globs
|
||||||
|
Makefile.in
|
||||||
|
*.DS_Store
|
||||||
|
*.sln.cache
|
||||||
|
*.suo
|
||||||
|
*.cache
|
||||||
|
*.pidb
|
||||||
|
*.userprefs
|
||||||
|
*.usertasks
|
||||||
|
config.log
|
||||||
|
config.make
|
||||||
|
config.status
|
||||||
|
aclocal.m4
|
||||||
|
install-sh
|
||||||
|
autom4te.cache/
|
||||||
|
*.user
|
||||||
|
*.tar.gz
|
||||||
|
tarballs/
|
||||||
|
test-results/
|
||||||
|
Thumbs.db
|
||||||
|
.vs/
|
||||||
|
|
||||||
|
# Mac bundle stuff
|
||||||
|
*.dmg
|
||||||
|
*.app
|
||||||
|
|
||||||
|
# resharper
|
||||||
|
*_Resharper.*
|
||||||
|
*.Resharper
|
||||||
|
|
||||||
|
# dotCover
|
||||||
|
*.dotCover
|
|
@ -0,0 +1,34 @@
|
||||||
|
|
||||||
|
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}") = "ln.templates.http", "ln.templates.http\ln.templates.http.csproj", "{91A99735-380C-4D9D-B16F-13A4D9CD00D6}"
|
||||||
|
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
|
||||||
|
{91A99735-380C-4D9D-B16F-13A4D9CD00D6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{91A99735-380C-4D9D-B16F-13A4D9CD00D6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{91A99735-380C-4D9D-B16F-13A4D9CD00D6}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{91A99735-380C-4D9D-B16F-13A4D9CD00D6}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{91A99735-380C-4D9D-B16F-13A4D9CD00D6}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{91A99735-380C-4D9D-B16F-13A4D9CD00D6}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{91A99735-380C-4D9D-B16F-13A4D9CD00D6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{91A99735-380C-4D9D-B16F-13A4D9CD00D6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{91A99735-380C-4D9D-B16F-13A4D9CD00D6}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{91A99735-380C-4D9D-B16F-13A4D9CD00D6}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{91A99735-380C-4D9D-B16F-13A4D9CD00D6}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{91A99735-380C-4D9D-B16F-13A4D9CD00D6}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,36 @@
|
||||||
|
using System;
|
||||||
|
using ln.http;
|
||||||
|
using ln.http.exceptions;
|
||||||
|
using ln.http.router;
|
||||||
|
using ln.templates.html;
|
||||||
|
|
||||||
|
namespace ln.templates.http
|
||||||
|
{
|
||||||
|
public delegate void PrepareRenderContext(TemplateRouter templateRouter,TemplateDocument templateDocument, RenderContext renderContext);
|
||||||
|
public class TemplateRouter : IHttpRouter
|
||||||
|
{
|
||||||
|
ITemplateSource TemplateSource { get; }
|
||||||
|
|
||||||
|
public event PrepareRenderContext OnPrepareRenderContext;
|
||||||
|
|
||||||
|
public TemplateRouter(ITemplateSource templateSource)
|
||||||
|
{
|
||||||
|
TemplateSource = templateSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HttpResponse Route(HttpRoutingContext routingContext, HttpRequest httpRequest)
|
||||||
|
{
|
||||||
|
TemplateDocument document = TemplateSource.GetTemplateByPath(routingContext.Path);
|
||||||
|
if (document != null)
|
||||||
|
{
|
||||||
|
HttpResponse response = new HttpResponse(httpRequest);
|
||||||
|
RenderContext renderContext = new RenderContext(response.ContentWriter, TemplateSource);
|
||||||
|
OnPrepareRenderContext?.Invoke(this, document, renderContext);
|
||||||
|
document.RenderTemplate(renderContext);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<Version>0.0.1-test</Version>
|
||||||
|
<Authors>Harald Wolff-Thobaben</Authors>
|
||||||
|
<Company>l--n.de</Company>
|
||||||
|
<Description>A IHttpRouter for delivering TemplateDocuments</Description>
|
||||||
|
<Copyright>(c) 2020 Harald Wolff-Thobaben</Copyright>
|
||||||
|
<PackageTags></PackageTags>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="ln.http" Version="0.1.2"/>
|
||||||
|
<PackageReference Include="ln.templates" Version="0.1.0"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
Loading…
Reference in New Issue