Reprise 1.0.1
See the version list below for details.
dotnet add package Reprise --version 1.0.1
NuGet\Install-Package Reprise -Version 1.0.1
<PackageReference Include="Reprise" Version="1.0.1" />
paket add Reprise --version 1.0.1
#r "nuget: Reprise, 1.0.1"
// 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
Create a new ASP.NET Core empty project.
Install the Reprise NuGet package.
Modify your
Program.cs
to use Reprise.
var builder = WebApplication.CreateBuilder(args);
builder.ConfigureServices();
var app = builder.Build();
app.MapEndpoints();
app.Run();
- Create an endpoint
Endpoints/GetHelloEndpoint.cs
.
[Endpoint]
public class GetHelloEndpoint
{
[Get("/")]
public static string Handle() => "Hello, world!";
}
- 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 | Versions 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. |
-
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 | 396 | 7/16/2023 |
3.6.0 | 205 | 7/12/2023 |
3.5.0 | 267 | 4/30/2023 |
3.4.2 | 367 | 2/20/2023 |
3.4.1 | 300 | 2/16/2023 |
3.4.0 | 302 | 2/5/2023 |
3.3.1 | 254 | 2/3/2023 |
3.3.0 | 288 | 2/1/2023 |
3.2.0 | 318 | 1/20/2023 |
3.1.6 | 336 | 12/20/2022 |
3.1.5 | 312 | 12/18/2022 |
3.1.4 | 301 | 12/12/2022 |
3.1.3 | 306 | 12/11/2022 |
3.1.2 | 355 | 12/4/2022 |
3.1.1 | 345 | 11/30/2022 |
3.1.0 | 331 | 11/27/2022 |
3.0.0 | 328 | 11/26/2022 |
2.2.0 | 357 | 11/23/2022 |
2.1.0 | 373 | 11/21/2022 |
2.0.0 | 348 | 11/19/2022 |
1.1.0 | 375 | 10/30/2022 |
1.0.3 | 425 | 10/22/2022 |
1.0.2 | 407 | 10/21/2022 |
1.0.1 | 427 | 10/20/2022 |
1.0.0 | 1,177 | 10/19/2022 |