25 lines
580 B
C#
25 lines
580 B
C#
using FastEndpoints;
|
|
|
|
namespace SpaceGame.Api.PlayerFaction.Api;
|
|
|
|
public sealed class GetPlayerFactionHandler(WorldService worldService) : EndpointWithoutRequest<PlayerFactionSnapshot>
|
|
{
|
|
public override void Configure()
|
|
{
|
|
Get("/api/player-faction");
|
|
AllowAnonymous();
|
|
}
|
|
|
|
public override async Task HandleAsync(CancellationToken cancellationToken)
|
|
{
|
|
var snapshot = worldService.GetPlayerFaction();
|
|
if (snapshot is null)
|
|
{
|
|
await SendNotFoundAsync(cancellationToken);
|
|
return;
|
|
}
|
|
|
|
await SendOkAsync(snapshot, cancellationToken);
|
|
}
|
|
}
|