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 | |
| .AddAuthenticationJwtBearer(s => s.SigningKey = bld.Configuration["Auth:JwtKey"]) | |
| .AddAuthorization() | |
| .AddFastEndpoints(); | |
| var app = bld.Build(); | |
| app.UseAuthentication() | |
| .UseAuthorization() | |
| .UseFastEndpoints(); |
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
| using System.Xml.Serialization; | |
| using Microsoft.AspNetCore.Http.Metadata; | |
| var bld = WebApplication.CreateBuilder(); | |
| bld.Services | |
| .AddSingleton(typeof(IRequestBinder<>), typeof(NegotiatingBinder<>)) | |
| .AddFastEndpoints() | |
| .SwaggerDocument(o => o.SerializerSettings = s => s.PropertyNamingPolicy = null); | |
| var app = bld.Build(); |
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
| { | |
| "diagnosticMessages": true | |
| } |
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 | |
| .Configure<JwtSigningOptions>(s => s.SigningKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") //must register signing options | |
| .Configure<JwtCreationOptions>(c => c.SigningKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") //optional | |
| .SwaggerDocument() | |
| .AddAuthenticationJwtBearer(s => { }) //no need to specify signing options here due to above | |
| .AddAuthorization() | |
| .AddFastEndpoints(); | |
| var app = bld.Build(); |
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
| sealed class MyEvent : IEvent | |
| { | |
| public string? Message { get; set; } | |
| } | |
| sealed class MyEventHandler : IEventHandler<MyEvent> | |
| { | |
| public Task HandleAsync(MyEvent e, CancellationToken c) | |
| => Task.CompletedTask; | |
| } |
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) => | |
| { |
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() | |
| .UseSwaggerGen(); | |
| app.Run(); |
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
| using FastEndpoints.Swagger; | |
| using Scalar.AspNetCore; //dotnet add package Scalar.AspNetCore | |
| var bld = WebApplication.CreateBuilder(args); | |
| bld.Services | |
| .AddFastEndpoints() | |
| .SwaggerDocument(); //define a swagger doc - v1 by default | |
| var app = bld.Build(); | |
| app.UseFastEndpoints(); //must come before the UseOpenApi() call |
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
| [HttpGet("publish"), AllowAnonymous] | |
| sealed class MyEndpoint : EndpointWithoutRequest | |
| { | |
| public override async Task HandleAsync(CancellationToken c) | |
| { | |
| var evnt = new MyEvent { Message = "hello!" }; | |
| await PublishAsync(evnt); | |
| await Send.OkAsync("all good!"); | |
| } | |
| } |
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.Errors.UseProblemDetails(); |
NewerOlder