-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestEndpointAttribute.cs
More file actions
93 lines (80 loc) · 1.92 KB
/
Copy pathRestEndpointAttribute.cs
File metadata and controls
93 lines (80 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
namespace CLOOPS.microservices;
/// <summary>
/// Defines whether a REST endpoint requires the SDK REST shared secret.
/// </summary>
public enum RestAuth
{
/// <summary>
/// The endpoint is callable without REST authentication.
/// </summary>
Public,
/// <summary>
/// The endpoint requires REST authentication.
/// </summary>
Required
}
/// <summary>
/// Supported lightweight REST endpoint HTTP methods.
/// </summary>
public enum RestHttpMethod
{
/// <summary>
/// HTTP DELETE.
/// </summary>
Delete,
/// <summary>
/// HTTP GET.
/// </summary>
Get,
/// <summary>
/// HTTP HEAD.
/// </summary>
Head,
/// <summary>
/// HTTP OPTIONS.
/// </summary>
Options,
/// <summary>
/// HTTP PATCH.
/// </summary>
Patch,
/// <summary>
/// HTTP POST.
/// </summary>
Post,
/// <summary>
/// HTTP PUT.
/// </summary>
Put
}
/// <summary>
/// Marks a method as a lightweight REST endpoint.
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
public sealed class RestEndpointAttribute : Attribute
{
/// <summary>
/// Creates a REST endpoint mapping.
/// </summary>
/// <param name="method">The HTTP method.</param>
/// <param name="path">The absolute endpoint path, for example /healthz.</param>
/// <param name="auth">The endpoint authentication mode.</param>
public RestEndpointAttribute(RestHttpMethod method, string path, RestAuth auth)
{
Method = method;
Path = path;
Auth = auth;
}
/// <summary>
/// Gets the HTTP method.
/// </summary>
public RestHttpMethod Method { get; }
/// <summary>
/// Gets the endpoint path.
/// </summary>
public string Path { get; }
/// <summary>
/// Gets the endpoint authentication mode.
/// </summary>
public RestAuth Auth { get; }
}