This file contains 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
sealed class OperationCancelledFilter : IEndpointFilter | |
{ | |
private readonly ILogger<OperationCancelledFilter> logger; | |
public OperationCancelledFilter(ILogger<OperationCancelledFilter> logger) | |
{ | |
this.logger = logger; | |
} | |
public async ValueTask<object?> InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next) |
This file contains 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
internal sealed class AddCustomHeader : IOperationProcessor | |
{ | |
public bool Process(OperationProcessorContext context) | |
{ | |
var hdrParameter = new OpenApiParameter() | |
{ | |
Name = "x-custom", | |
Kind = OpenApiParameterKind.Header, | |
IsRequired = true, | |
Type = JsonObjectType.String, |
This file contains 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
sealed class MyRequest | |
{ | |
public int Id { get; set; } | |
} | |
public sealed class MyCommand : ICommand<int> | |
{ | |
public string Identity { get; set; } | |
} |
This file contains 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
using Asp.Versioning; | |
using Asp.Versioning.Conventions; | |
using FastEndpoints; | |
using FastEndpoints.AspVersioning; | |
using FastEndpoints.Swagger; | |
VersionSets.CreateApi(">>Orders<<", v => v | |
.HasApiVersion(1.0) | |
.HasApiVersion(2.0)); |
This file contains 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
public sealed class Endpoint : EndpointWithoutRequest | |
{ | |
public override void Configure() | |
{ | |
Get("/protected"); | |
Claims("userId"); | |
Roles("Some_Role_Name"); | |
Permissions("Some_Permission"); | |
} |
This file contains 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(); | |
bld.Services | |
.AddFastEndpoints() | |
.SwaggerDocument(o => | |
{ | |
o.DocumentSettings = s => | |
{ | |
s.DocumentName = "Initial Release"; | |
s.Version = "v0"; | |
}; |
This file contains 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
using FastEndpoints; | |
using FastEndpoints.Swagger; | |
var bld = WebApplication.CreateBuilder(args); | |
bld.Services.AddFastEndpoints(); | |
bld.Services.AddRazorPages(); | |
bld.Services.AddServerSideBlazor(); | |
bld.Services.SwaggerDocument(); | |
var app = bld.Build(); |
This file contains 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(); | |
bld.Services | |
.AddSingleton(typeof(IRequestBinder<>), typeof(CustomBinder<>)) | |
.AddFastEndpoints() | |
.SwaggerDocument(); | |
var app = bld.Build(); | |
app.UseAuthorization() | |
.UseFastEndpoints() | |
.UseSwaggerGen(); |
This file contains 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 builder = WebApplication.CreateBuilder(); | |
builder.Services.AddFastEndpoints(); | |
var app = builder.Build(); | |
app.UseRouting(); //should be before auth/cors/fastendpoints middlewares. | |
app.UseAuthorization(); | |
app.UseFastEndpoints(); | |
app.UseEndpoints(_ => { }); //should be right after UseFastEndpoints(). this is the terminating middleware for endpoint routes. | |
if (app.Environment.IsDevelopment()) |
This file contains 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
using Ardalis.Result; | |
using FastEndpoints; | |
using FastEndpoints.Swagger; | |
var bld = WebApplication.CreateBuilder(); | |
bld.Services | |
.AddFastEndpoints() | |
.SwaggerDocument(); | |
var app = bld.Build(); |