Repository navigation
Expand file tree
/
Copy pathNodeInfoEndpointRouteExtensions.cs
More file actions
92 lines (81 loc) · 3.41 KB
/
Copy pathNodeInfoEndpointRouteExtensions.cs
File metadata and controls
92 lines (81 loc) · 3.41 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
using GeFeSLE;
public static class NodeInfoEndpointRouteExtensions
{
public static IEndpointRouteBuilder MapNodeInfoEndpoints(this IEndpointRouteBuilder endpoints)
{
static void Trace(string fn)
{
DBg.d(LogLevel.Trace, fn);
}
static RouteHandlerBuilder MapNodeInfoVersion(
IEndpointRouteBuilder routeBuilder,
string path,
Func<string, GeFeSLEDb, Task<IResult>> handler)
{
return routeBuilder.MapGet(path, async (GeFeSLEDb db) =>
{
string fn = $"{path} (GET)";
Trace(fn);
return await handler(fn, db);
}).AllowAnonymous();
}
endpoints.MapGet("/.well-known/nodeinfo", () =>
{
string fn = "/.well-known/nodeinfo (GET)";
Trace(fn);
return NodeInfoEndpointService.GetDiscoveryDocument(fn);
})
.WithEndpointDocs("nodeinfo.discovery.get")
.AllowAnonymous();
endpoints.MapGet("/.well-known/x-nodeinfo2", () =>
{
string fn = "/.well-known/x-nodeinfo2 (GET)";
Trace(fn);
return NodeInfoEndpointService.GetDiscoveryDocument(fn);
})
.AllowAnonymous();
MapNodeInfoVersion(endpoints, "/nodeinfo/1.0", NodeInfoEndpointService.GetNodeInfo10DocumentAsync);
MapNodeInfoVersion(endpoints, "/nodeinfo/1.0.json", NodeInfoEndpointService.GetNodeInfo10DocumentAsync);
MapNodeInfoVersion(endpoints, "/nodeinfo/2.0", NodeInfoEndpointService.GetNodeInfo20DocumentAsync);
MapNodeInfoVersion(endpoints, "/nodeinfo/2.0.json", NodeInfoEndpointService.GetNodeInfo20DocumentAsync);
MapNodeInfoVersion(endpoints, "/nodeinfo/2.1", NodeInfoEndpointService.GetNodeInfo21DocumentAsync)
.WithEndpointDocs("nodeinfo.2_1.get");
MapNodeInfoVersion(endpoints, "/nodeinfo/2.1.json", NodeInfoEndpointService.GetNodeInfo21DocumentAsync);
endpoints.MapGet("/statistics.json", async (GeFeSLEDb db) =>
{
string fn = "/statistics.json (GET)";
Trace(fn);
return await NodeInfoEndpointService.GetStatisticsDocumentAsync(fn, db);
})
.AllowAnonymous();
endpoints.MapGet("/status.php", () =>
{
string fn = "/status.php (GET)";
Trace(fn);
return NodeInfoEndpointService.GetStatusDocument(fn);
})
.AllowAnonymous();
endpoints.MapGet("/.well-known/host-meta", () =>
{
string fn = "/.well-known/host-meta (GET)";
Trace(fn);
return NodeInfoEndpointService.GetHostMetaDocument(fn);
})
.AllowAnonymous();
endpoints.MapGet("/xrpc/com.atproto.server.describeServer", () =>
{
string fn = "/xrpc/com.atproto.server.describeServer (GET)";
Trace(fn);
return NodeInfoEndpointService.GetAtProtoDescribeServerDocument(fn);
})
.AllowAnonymous();
endpoints.MapGet("/xrpc/_health", () =>
{
string fn = "/xrpc/_health (GET)";
Trace(fn);
return NodeInfoEndpointService.GetAtProtoHealthDocument(fn);
})
.AllowAnonymous();
return endpoints;
}
}