tangled
alpha
login
or
join now
dwn.poxiao-labs.work
/
AtmoType
0
fork
atom
AtmoType is a font sharing website through ATProto.
0
fork
atom
overview
issues
pulls
pipelines
[be] add example endpoint
dwn.poxiao-labs.work
2 months ago
7b5bc202
288621f6
+58
-1
4 changed files
expand all
collapse all
unified
split
AtmoType
AtmoType.csproj
Endpoints
Example
Example.cs
Program.cs
XrpcBase.cs
+1
AtmoType/AtmoType.csproj
···
7
7
</PropertyGroup>
8
8
9
9
<ItemGroup>
10
10
+
<PackageReference Include="FastEndpoints" Version="7.1.1" />
10
11
<PackageReference Include="FishyFlip" Version="4.2.0" />
11
12
</ItemGroup>
12
13
+24
AtmoType/Endpoints/Example/Example.cs
···
1
1
+
namespace AtmoType.Endpoints.Example;
2
2
+
3
3
+
public class ExampleRequest
4
4
+
{
5
5
+
public string? Name { get; set; }
6
6
+
}
7
7
+
8
8
+
public class ExampleResponse
9
9
+
{
10
10
+
public string Hello { get; set; } = string.Empty;
11
11
+
}
12
12
+
13
13
+
public class Example : XrpcQuery<ExampleRequest, ExampleResponse>
14
14
+
{
15
15
+
public override string Nsid => "win.atmotype.example.example";
16
16
+
17
17
+
public override async Task<ExampleResponse> ExecuteAsync(ExampleRequest req, CancellationToken ct)
18
18
+
{
19
19
+
return new ExampleResponse
20
20
+
{
21
21
+
Hello = "world"
22
22
+
};
23
23
+
}
24
24
+
}
+4
-1
AtmoType/Program.cs
···
1
1
+
using FastEndpoints;
2
2
+
1
3
var builder = WebApplication.CreateBuilder(args);
4
4
+
builder.Services.AddFastEndpoints();
2
5
var app = builder.Build();
3
6
7
7
+
app.UseFastEndpoints();
4
8
app.MapGet("/", () => "Hello World!");
5
5
-
6
9
app.Run();
+29
AtmoType/XrpcBase.cs
···
1
1
+
using FastEndpoints;
2
2
+
3
3
+
namespace AtmoType;
4
4
+
5
5
+
public abstract class XrpcQuery<TRequest, TResponse> : Endpoint<TRequest, TResponse>
6
6
+
where TRequest : notnull
7
7
+
where TResponse : notnull
8
8
+
{
9
9
+
public abstract string Nsid { get; }
10
10
+
11
11
+
public override void Configure()
12
12
+
{
13
13
+
Get($"/xrpc/{Nsid}");
14
14
+
AllowAnonymous(); // TODO: Better auth support
15
15
+
}
16
16
+
}
17
17
+
18
18
+
public abstract class XrpcProcedure<TRequest, TResponse> : Endpoint<TRequest, TResponse>
19
19
+
where TRequest : notnull
20
20
+
where TResponse : notnull
21
21
+
{
22
22
+
public abstract string Nsid { get; }
23
23
+
24
24
+
public override void Configure()
25
25
+
{
26
26
+
Post($"/xrpc/{Nsid}");
27
27
+
AllowAnonymous(); // TODO: Better auth support
28
28
+
}
29
29
+
}