Skip to content

Instantly share code, notes, and snippets.

@EelcoLos
Last active January 27, 2026 10:49
Show Gist options
  • Select an option

  • Save EelcoLos/1c5f3c6be9ac765719ee880f3dcfec71 to your computer and use it in GitHub Desktop.

Select an option

Save EelcoLos/1c5f3c6be9ac765719ee880f3dcfec71 to your computer and use it in GitHub Desktop.
FastEndpoints using dotnet 10 file-based app structure
#:sdk Microsoft.NET.Sdk.Web
#:package FastEndpoints@7.*-*
#:property PublishAot=false
using FastEndpoints;
var builder = WebApplication.CreateBuilder();
builder.Services.AddFastEndpoints();
var app = builder.Build();
app.UseFastEndpoints();
app.Run();
public record MyRequest(string FirstName, string LastName, int Age);
public record MyResponse(string FullName, bool IsOver18);
public class MyEndpoint : Endpoint<MyRequest, MyResponse>
{
public override void Configure()
{
Post("/api/user/create");
AllowAnonymous();
}
public override Task HandleAsync(MyRequest req, CancellationToken ct) =>
Send.OkAsync(new($"{req.FirstName} {req.LastName}", req.Age >= 18), cancellation: ct);
}
#:sdk Microsoft.NET.Sdk.Web
#:package FastEndpoints@7.*-*
#:property PublishAot=false
using FastEndpoints;
var builder = WebApplication.CreateBuilder();
builder.Services.AddFastEndpoints();
var app = builder.Build();
app.UseFastEndpoints();
app.Run();
public record MyRequest(string FirstName, string LastName, int Age);
public record MyResponse(string FullName, bool IsOver18);
[HttpPost("/api/user/create")]
[Microsoft.AspNetCore.Authorization.AllowAnonymous()]
public class MyEndpoint : Endpoint<MyRequest, MyResponse>
{
public override Task HandleAsync(MyRequest req, CancellationToken ct) =>
Send.OkAsync(new($"{req.FirstName} {req.LastName}", req.Age >= 18), cancellation: ct);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment