ln.http/ln.http.service/Program.cs

59 lines
1.7 KiB
C#

using System.IO;
using System.Reflection;
using ln.bootstrap;
using ln.templates;
using ln.templates.html;
namespace ln.http.service
{
class Program
{
static void Main(string[] args)
{
Bootstrap
.DefaultInstance
//.AddService<HttpServiceHelper>()
.Start();
}
}
/*
class HttpServiceHelper : HttpRouter
{
private TemplateDocument _templateDocument;
public HttpServiceHelper(HttpRouter httpRouter)
:base()
{
using (StreamReader reader = new StreamReader(
Assembly
.GetExecutingAssembly()
.GetManifestResourceStream("ln.http.service.error.html")
)
)
{
_templateDocument = TemplateReader.ReadTemplate(reader);
}
Map(HttpMethod.ANY, "/_err.html", HttpRoutePriority.LOW, this.HttpError);
}
bool HttpError(HttpContext httpContext)
{
HttpResponse httpResponse =
new HttpResponse(httpContext.HttpException?.HttpStatusCode ?? HttpStatusCode.InternalServerError);
RenderContext renderContext = new RenderContext(httpResponse.ContentWriter);
renderContext
.GetEngine()
.SetValue("httpContext", httpContext);
_templateDocument.RenderTemplate(renderContext);
httpContext.Response = httpResponse;
return true;
}
}
*/
}