Adds Messaging streaming
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
using FastEndpoints;
|
||||
using Hutopy.Web.Features.Contents.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Hutopy.Web.Features.Contents.Handlers;
|
||||
|
||||
public sealed class GetContentsRequest
|
||||
{
|
||||
public Guid ContentId { get; set; }
|
||||
}
|
||||
|
||||
public class GetContents(
|
||||
ContentDbContext context)
|
||||
: Endpoint<GetContentsRequest, Content>
|
||||
{
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/api/contents/{ContentId:guid}");
|
||||
Options(o => o.WithTags("Contents"));
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(
|
||||
GetContentsRequest req,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var content = await context
|
||||
.Contents
|
||||
.FirstOrDefaultAsync(
|
||||
c => c.Id == req.ContentId,
|
||||
cancellationToken: ct);
|
||||
|
||||
if (content is null)
|
||||
await SendNotFoundAsync(cancellation: ct);
|
||||
else
|
||||
await SendAsync(content, cancellation: ct);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user