MinimalApi.Endpoint 1.0.1

StructuredMinimalApi

The goal of this project it's to define one endpoint (minimal API .net 6) by one file (class)

Program.cs

Use AddEndpoints extenion method to create each endpoint.

And also MapEndpoint extension method to use new routing APIs

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddEndpoints();

var app = builder.Build();

app.MapEndpoints();

app.Run();

Define an endpoint

To create and define one endpoint, it need to implement IEndpoint interface

public class GetWithParamEndpoint : IEndpoint<string, string>
    {
        public void AddRoute(IEndpointRouteBuilder app)
        {
            app.MapGet("/Todo/2/{param1}", (string param1) => HandleAsync(param1));
        }

        public Task<string> HandleAsync(string request)
        {
            return Task.FromResult($"Hello World! 2 {request}");
        }
    }

Nuget Package

A nuget package it's available here.

No packages depend on MinimalApi.Endpoint.

Version Downloads Last updated
1.3.0 30 01/13/2024
1.2.0 26 03/11/2024
1.1.1 30 03/11/2024
1.1.0 34 03/11/2024
1.0.1 29 03/11/2024
1.0.0 28 03/11/2024