Reprise 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Reprise --version 1.0.1                
NuGet\Install-Package Reprise -Version 1.0.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="Reprise" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Reprise --version 1.0.1                
#r "nuget: Reprise, 1.0.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 Reprise as a Cake Addin
#addin nuget:?package=Reprise&version=1.0.1

// Install Reprise as a Cake Tool
#tool nuget:?package=Reprise&version=1.0.1                

Reprise

Reprise is a micro-framework that brings the REPR (Request-Endpoint-Response) pattern and vertical slice architecture into ASP.NET Core Minimal APIs.

Getting Started

  1. Create a new ASP.NET Core empty project.

  2. Install the Reprise NuGet package.

  3. Modify your Program.cs to use Reprise.

var builder = WebApplication.CreateBuilder(args);
builder.ConfigureServices();
var app = builder.Build();
app.MapEndpoints();
app.Run();
  1. Create an endpoint Endpoints/GetHelloEndpoint.cs.
[Endpoint]
public class GetHelloEndpoint
{
    [Get("/")]
    public static string Handle() => "Hello, world!";
}
  1. Run the application.

Endpoints

An endpoint is a public class that is decorated with the EndpointAttribute. It should contain a public static Handle method which should be decorated with one of the HTTP method and route attributes. These are:

  • GetAttribute
  • PostAttribute
  • PutAttribute
  • PatchAttribute
  • DeleteAttribute
  • MapAttribute - for other/multiple HTTP methods

The Handle method can be synchronous as well as asynchronous and can have any signature and any return type.

[Endpoint]
public class UpdateUserEndpoint
{
    [Authorize]
    [Put("/users/{id}")]
    public static IResult Handle(int id, UserDto userDto, DataContext context)
    {
        // ...
    }
}

In the example id comes from the route, userDto - from the body, and context - from the DI container. Check the Minimal APIs documentation for more information on the topic.

On application startup, app.MapEndpoints() and app.MapEndpoints(assembly) perform an assebly scan and map all endpoints. Reprise will throw an InvalidOperationExcaption when:

  • An endpoint has no Handle method
  • An endpoint has multiple Handle methods
  • The Handle method has no HTTP method and route attribute
  • The Handle method has an empty route
  • The Handle method has an empty HTTP method
  • A HTTP method and route combination is handled by more than one endpoint

Services

Any class that has a public parameterless constructor and implements IServiceConfgurator can configure services.

[Endpoint]
public class GetWeather : IServiceConfigurator
{
    public void ConfigureServices(WebApplicationBuilder builder)
    {
        builder.Services.AddWeatherService();
    }

    [Get("/weather")]
    public static async Task<WeatherForecast[]> Handle(IWeatherService weatherService)
    {
        return await weatherService.GetForecast();
    }
}

On application startup, builder.ConfigureServices() and builder.ConfigureServices(assembly) perform an assebly scan and invoke all ConfigureServices(WebApplicationBuilder builder) implementations. Reprise will throw an InvalidOperationException if a service configurator has no public paramereterless constructor.

OpenAPI

In order to group endpoints in the Swagger UI, Reprise extracts a tag from the route of every endpoint. The first segment that is not "api" (case insensitive) or a parameter is capitalized and set as a tag. "/" is used when no match is found.

Performance

Besides the assembly scans at application startup when configuring services and mapping endpoints, Reprise doesn't add any performance overhead when handling requests.

Support

If you spot any problems and/or have improvement ideas, please share them via the issue tracker.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.7.0 392 7/16/2023
3.6.0 203 7/12/2023
3.5.0 265 4/30/2023
3.4.2 365 2/20/2023
3.4.1 298 2/16/2023
3.4.0 300 2/5/2023
3.3.1 252 2/3/2023
3.3.0 286 2/1/2023
3.2.0 316 1/20/2023
3.1.6 334 12/20/2022
3.1.5 310 12/18/2022
3.1.4 299 12/12/2022
3.1.3 304 12/11/2022
3.1.2 353 12/4/2022
3.1.1 343 11/30/2022
3.1.0 329 11/27/2022
3.0.0 326 11/26/2022
2.2.0 355 11/23/2022
2.1.0 371 11/21/2022
2.0.0 346 11/19/2022
1.1.0 373 10/30/2022
1.0.3 423 10/22/2022
1.0.2 405 10/21/2022
1.0.1 425 10/20/2022
1.0.0 1,160 10/19/2022