Created
January 30, 2025 13:16
-
-
Save dj-nitehawk/be15f1125cafc4ddd1c233eca26c0a8a to your computer and use it in GitHub Desktop.
Global response modifier
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
var bld = WebApplication.CreateBuilder(args); | |
bld.Services | |
.SwaggerDocument() | |
.AddFastEndpoints(); | |
var app = bld.Build(); | |
app.UseFastEndpoints( | |
c => c.Endpoints.GlobalResponseModifier | |
= (ctx, content) => | |
{ | |
ctx.Response.Headers.Append("x-some-header", content as string); | |
}) | |
.UseSwaggerGen(); | |
app.Run(); | |
sealed class SomeEndpoint : Ep.NoReq.Res<string> | |
{ | |
public override void Configure() | |
{ | |
Get("some-endpoint"); | |
AllowAnonymous(); | |
} | |
public override async Task HandleAsync(CancellationToken ct) | |
{ | |
await SendAsync("hello world!"); | |
} | |
} |
That worked perfectly. Thank you for your help.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@tmorejon
try this: https://fast-endpoints.com/docs/configuration-settings#custom-response-dto-serialization