Browse Source

Initial Commit

master
Harald Wolff 11 months ago
commit
453ec7234b
  1. 41
      .gitignore
  2. 34
      ln.templates.http.sln
  3. 36
      ln.templates.http/TemplateRouter.cs
  4. 21
      ln.templates.http/ln.templates.http.csproj

41
.gitignore

@ -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

34
ln.templates.http.sln

@ -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

36
ln.templates.http/TemplateRouter.cs

@ -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;
}
}
}

21
ln.templates.http/ln.templates.http.csproj

@ -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…
Cancel
Save