Repository navigation
Expand file tree
/
Copy pathAppDelegates.cs
More file actions
76 lines (60 loc) · 2.36 KB
/
Copy pathAppDelegates.cs
File metadata and controls
76 lines (60 loc) · 2.36 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#if !NETCORE
using System.Web;
#endif
using System;
using System.Threading.Tasks;
using ServiceStack.Web;
namespace ServiceStack.Host
{
public delegate IHttpHandler HttpHandlerResolverDelegate(string httpMethod, string pathInfo, string filePath);
public delegate bool StreamSerializerResolverDelegate(IRequest requestContext, object dto, IResponse httpRes);
public delegate void HandleUncaughtExceptionDelegate(
IRequest httpReq, IResponse httpRes, string operationName, Exception ex);
public delegate Task HandleUncaughtExceptionAsyncDelegate(
IRequest httpReq, IResponse httpRes, string operationName, Exception ex);
public delegate object HandleServiceExceptionDelegate(IRequest httpReq, object request, Exception ex);
public delegate Task<object> HandleServiceExceptionAsyncDelegate(IRequest httpReq, object request, Exception ex);
public delegate void HandleGatewayExceptionDelegate(IRequest httpReq, object request, Exception ex);
public delegate Task HandleGatewayExceptionAsyncDelegate(IRequest httpReq, object request, Exception ex);
public delegate RestPath FallbackRestPathDelegate(IHttpRequest httpReq);
public interface ITypedFilter
{
void Invoke(IRequest req, IResponse res, object dto);
}
public interface ITypedFilterAsync
{
Task InvokeAsync(IRequest req, IResponse res, object dto);
}
public interface ITypedFilter<in T>
{
void Invoke(IRequest req, IResponse res, T dto);
}
public interface ITypedFilterAsync<in T>
{
Task InvokeAsync(IRequest req, IResponse res, T dto);
}
public class TypedFilter<T> : ITypedFilter
{
private readonly Action<IRequest, IResponse, T> action;
public TypedFilter(Action<IRequest, IResponse, T> action)
{
this.action = action;
}
public void Invoke(IRequest req, IResponse res, object dto)
{
action(req, res, (T)dto);
}
}
public class TypedFilterAsync<T> : ITypedFilterAsync
{
private readonly Func<IRequest, IResponse, T, Task> action;
public TypedFilterAsync(Func<IRequest, IResponse, T, Task> action)
{
this.action = action;
}
public async Task InvokeAsync(IRequest req, IResponse res, object dto)
{
await action(req, res, (T)dto);
}
}
}