MadEyeMatt.AspNetCore.Endpoints 8.0.5

dotnet add package MadEyeMatt.AspNetCore.Endpoints --version 8.0.5
NuGet\Install-Package MadEyeMatt.AspNetCore.Endpoints -Version 8.0.5
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="MadEyeMatt.AspNetCore.Endpoints" Version="8.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MadEyeMatt.AspNetCore.Endpoints --version 8.0.5
#r "nuget: MadEyeMatt.AspNetCore.Endpoints, 8.0.5"
#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 MadEyeMatt.AspNetCore.Endpoints as a Cake Addin
#addin nuget:?package=MadEyeMatt.AspNetCore.Endpoints&version=8.0.5

// Install MadEyeMatt.AspNetCore.Endpoints as a Cake Tool
#tool nuget:?package=MadEyeMatt.AspNetCore.Endpoints&version=8.0.5

AspNetCore.Endpoints

A library that helps in building and configuring object-oriented minimal API endpoints.

Mapping every single minimal API endpoint in the Program.cs file can become confusing very fast. For applications hosting a larger amount of endpoints this library allows to implement an endpoint in a structured way. This endpoints will then be automatically mapped, removing clutter from the Program.cs file.

Everything related to and endpoint like the mapping and the implementation itself is encapsulated in a single class. The library offers a default way of naming groups and endpoints. The default convention for the group name an endpoint belongs to is the last part of the namespace the endpoint belongs to. The default convention for the endppoint name id the class name of the endpoint.

This default conventions can be overridden by using attributes athe endpoints class level.

  • [EndpointGroupName("GroupName")]

    The name of the group this endpoint belongs to.

  • [EndpointName("SomeOtherName")]

    The name of the endpoint.

Endpoints Usage

Every endpoint is implemented in it's own class, deriving from EndpointBase. Endpoints are discovered from the available types using this base class.


	public sealed class Get : EndpointBase
	{
		/// <inheritdoc />
		public override void Map(IEndpointRouteBuilder endpoints)
		{
			endpoints
				.MapGet(this.Execute, "{id}")
				.AllowAnonymous()
				.Produces<Customer>(200, "application/json");
		}

		public async Task<IResult> Execute(HttpContext httpContext, string id)
		{
			return Results.Ok(new Customer
			{
				Name = "John Connor"
			});
		}
	}

The mapping and configuration of additional meta data configuration of the endpoint is done in the Map method. The actual endpoint implementation is done in the Execute method. The name of the method free to choose, it doesn't affect the mapping of the endpoint in any way.

To allow the endpoint beeing automatically mapped one has to add this to the Program.cs:


app.MapEndpoints();

This it!

Additional Configuration

The endpoints are by default mapped under a global route prefix api. To change this default value, one can configure the EndpointsOptions when configuring the application.


	builder.Services.Configure<EndpointsOptions>(options =>
	{
		options.EndpointsRoutePrefix = "endpoints";
		options.MapGroup = groupBuilder =>
		{
			groupBuilder.WithOpenApi();
		};
	});

In this exampple the global route prefix for all enpoints is changed to endpoints and an additional endpoint group configuration is added using the MapGroup callback, which is called for every endpoint group.

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 is compatible.  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.
  • net8.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MadEyeMatt.AspNetCore.Endpoints:

Package Downloads
Fluxera.Extensions.Hosting.Modules.AspNetCore The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

A module that enables ASP.NET Core.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
8.0.5 1,193 4/19/2024
8.0.4 680 3/19/2024
8.0.3 2,668 11/24/2023
8.0.2 103 11/22/2023
8.0.1 450 11/17/2023
8.0.0 96 11/17/2023