MinimalApi.SlimEndpoints.Abstractions 1.3.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package MinimalApi.SlimEndpoints.Abstractions --version 1.3.1                
NuGet\Install-Package MinimalApi.SlimEndpoints.Abstractions -Version 1.3.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MinimalApi.SlimEndpoints.Abstractions" Version="1.3.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MinimalApi.SlimEndpoints.Abstractions --version 1.3.1                
#r "nuget: MinimalApi.SlimEndpoints.Abstractions, 1.3.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MinimalApi.SlimEndpoints.Abstractions as a Cake Addin
#addin nuget:?package=MinimalApi.SlimEndpoints.Abstractions&version=1.3.1

// Install MinimalApi.SlimEndpoints.Abstractions as a Cake Tool
#tool nuget:?package=MinimalApi.SlimEndpoints.Abstractions&version=1.3.1                

MinimalApi Slim Endpoints

Github actions Nuget feed

Small library for decoupling endpoints in MinimalApi from the Program.cs file.

This library does not add any additional overhead to the application, it just helps you to organize your code better.

The source generator will generate a DependencyInjection extension that will contain all the endpoints that you have defined in your application.

Installation

Install the package from NuGet:

dotnet add package MinimalApi.SlimEndpoints

Quick start

Create a class that inherits from ISlimEndpoint and implement the Configure and Handler methods. Add the SlimEndpoint attribute to the class.

SlimEndpoint attribute

The SlimEndpoint attribute has the following properties:

  • Path - The path of the endpoint. This is the same as the MapGet method in the MinimalApi.
  • HttpMethod - The HTTP method of the endpoint. This is the same as the MapGet method in the MinimalApi.

Configure method

The Configure method injects the RouteHandlerBuilder into the endpoint class. Leave the method empty if you don't need to configure the endpoint.

Handler method

The Handler method is the main method of the endpoint. It is called when the endpoint is hit.

Example

using MinimalApi.SlimEndpoints.Abstractions;

namespace SampleDemo.Endpoints;

[SlimEndpoint(Path = "/hello", Method = "GET")]
public partial class HelloEndpoint : ISlimEndpoint
{
    public void Configure(RouteHandlerBuilder builder)
    {
        builder.AllowAnonymous();
    }

    public Delegate Handler => (() => "Hello World!");
}

Dependency Injection configuration

The MinimalApi.SlimEndpoints library uses the Microsoft.Extensions.DependencyInjection library for dependency injection. You can configure the DI container in the Program.cs file.

var builder = WebApplication.CreateBuilder(args);

// Register endpoints
builder.Services.AddSlimEndpoints();

var app = builder.Build();

// Map endpoints
app.MapSlimEndpoints();

app.Run();

License

MIT

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MinimalApi.SlimEndpoints.Abstractions:

Package Downloads
MinimalApi.SlimEndpoints

Minimal Api Slim Endpoints Extension

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.3 451 1/16/2023
1.3.2 320 1/14/2023
1.3.1 314 1/13/2023
1.2.1-release-g982b77e2d6 179 1/12/2023
1.1.1-g64231a551d 158 1/12/2023
1.0.5-g83325a6b56 176 1/12/2023