forked from xamarin/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRazorHandler.cs
More file actions
48 lines (40 loc) · 1.26 KB
/
Copy pathRazorHandler.cs
File metadata and controls
48 lines (40 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using System.Net;
using ServiceStack.ServiceHost;
using ServiceStack.Text;
using ServiceStack.WebHost.Endpoints.Support;
namespace ServiceStack.RazorEngine
{
public class RazorHandler : EndpointHandlerBase
{
public RazorFormat RazorFormat { get; set; }
public RazorPage RazorPage { get; set; }
public string PathInfo { get; set; }
public string FilePath { get; set; }
public override void ProcessRequest(IHttpRequest httpReq, IHttpResponse httpRes, string operationName)
{
var contentPage = RazorPage;
if (contentPage == null)
{
var pageFilePath = this.FilePath.WithoutExtension();
contentPage = RazorFormat.GetContentPage(pageFilePath);
}
if (contentPage == null)
{
httpRes.StatusCode = (int)HttpStatusCode.NotFound;
return;
}
RazorFormat.ReloadModifiedPageAndTemplates(contentPage);
if (httpReq.DidReturn304NotModified(contentPage.GetLastModified(), httpRes))
return;
RazorFormat.ProcessRazorPage(httpReq, contentPage, null, httpRes);
}
public override object CreateRequest(IHttpRequest request, string operationName)
{
return null;
}
public override object GetResponse(IHttpRequest httpReq, IHttpResponse httpRes, object request)
{
return null;
}
}
}