Last active
January 27, 2026 10:49
-
-
Save EelcoLos/1c5f3c6be9ac765719ee880f3dcfec71 to your computer and use it in GitHub Desktop.
FastEndpoints using dotnet 10 file-based app structure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #: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); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #: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