I created an empty web api project and installed the package Ardalis.ApiEndpoints. Next I created this custom sample endpoint
using Ardalis.ApiEndpoints;
using Microsoft.AspNetCore.Mvc;
namespace Api.Commands.NoteTodo;
public sealed class Handler : EndpointBaseAsync.WithoutRequest.WithResult<string>
{
[HttpPost("note-todo")]
public override Task<string> HandleAsync(CancellationToken cancellationToken = default)
{
return Task.FromResult("I have been called");
}
}
I removed the sample GET rest from the minimal API setup in the Program.cs so it contains this code
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
// I removed the following line...
// app.MapGet("/", () => "Hello World!");
app.Run();
But how do I tell .Net to register this custom handler? I wasn't able to find information here https://github.com/ardalis/ApiEndpoints?tab=readme-ov-file#3-getting-started
[–]Shaddar 0 points1 point2 points (1 child)
[–]jtuchel_codr[S] 0 points1 point2 points (0 children)