forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloAppHost.cs
More file actions
60 lines (50 loc) · 1.92 KB
/
HelloAppHost.cs
File metadata and controls
60 lines (50 loc) · 1.92 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
49
50
51
52
53
54
55
56
57
58
59
60
using System.IO;
using System.Web;
using ServiceStack.Admin;
using ServiceStack.Web;
namespace ServiceStack.Razor.Tests
{
public class HelloAppHost : AppHostBase
{
public HelloAppHost()
: base("Hello Web Services", typeof(HelloService).Assembly) { }
public override void Configure(Funq.Container container)
{
//http://stackoverflow.com/questions/13206038/servicestack-razor-default-page/13206221
this.SetConfig(new HostConfig
{
DebugMode = true,
});
var razor3 = new RazorFormat();
this.Plugins.Add(razor3);
this.Plugins.Add(new RequestLogsFeature
{
EnableErrorTracking = true,
EnableResponseTracking = true,
EnableSessionTracking = true,
EnableRequestBodyTracking = true,
RequiredRoles = new string[0]
});
this.PreRequestFilters.Add(SimplePreRequestFilter);
this.GlobalRequestFilters.Add(SimpleRequestFilter);
this.Routes.Add<HelloRequest>("/hello");
this.Routes.Add<HelloRequest>("/hello/{Name}");
this.Routes.Add<FooRequest>("/Foo/{WhatToSay}");
this.Routes.Add<DefaultViewFooRequest>("/DefaultViewFoo/{WhatToSay}");
}
private void SimpleRequestFilter(IRequest req, IResponse res, object obj)
{
if (Path.GetFileName(req.PathInfo).StartsWith("_"))
{
throw new HttpException("FIles with leading underscore ('_') cannot be served.");
}
}
private void SimplePreRequestFilter(IRequest req, IResponse res)
{
if (Path.GetFileName(req.PathInfo).StartsWith("_"))
{
throw new HttpException("Files with leading underscores ('_') cannot be served.");
}
}
}
}