SharpEndpoint 0.0.2
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package SharpEndpoint --version 0.0.2
NuGet\Install-Package SharpEndpoint -Version 0.0.2
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="SharpEndpoint" Version="0.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SharpEndpoint" Version="0.0.2" />
<PackageReference Include="SharpEndpoint" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SharpEndpoint --version 0.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SharpEndpoint, 0.0.2"
#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.
#:package SharpEndpoint@0.0.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SharpEndpoint&version=0.0.2
#tool nuget:?package=SharpEndpoint&version=0.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
| Branch | Status |
|---|---|
| main |
Installation
SharpEndpointis a C# library based on minimal API that offers an opinionated way to organize minimal API endpoints.- To install, run
dotnet add package SharpEndpointor from Nuget
Usage Guide
- Crate a class and inherit it from
SharpEndpointFragment, then implement the required methods. - Override
RouteandRouteGroupon demand to set endpoint route. - Override
ConfigureRouteandConfigureRouteGroupfor providing configurations. - Constructor dependency injection is not allowed by design to stick with the minimal API convention.
- To map all the endpoints, Call
MapSharpEndpointFragmentsFromAssemblyin theProgram.csfile from theWebApplicationinstance. For example,
var app = builder.Build();
app.MapSharpEndpointFragmentsFromAssembly(typeof(Program).Assembly);
Default Choices
- The default
RouteandRouteGrouparestring.Empty - OpenAPI is enabled by default on both
RouteandRouteGroupbyWithOpenApi()inConfigureRouteandConfigureRouteGroup - To use the default configurations, use
..base.Configure()in the returnIEnumerable
Examples
- A complete REST API with CRUD functionality example is also given to showcase the usefulness of SharpOutcome. Source code is available here.
public class Update : SharpEndpointFragment
{
protected override string RouteGroup() => BookRouteConstants.BaseRoute;
protected override string Route() => BookRouteConstants.IdParam;
protected override HttpVerb Verb() => HttpVerb.PUT;
protected override IEnumerable<Action<RouteHandlerBuilder>> ConfigureRoute()
{
return
[
..base.ConfigureRoute(),
e => e.WithSummary("update a book"),
e => e.Produces(StatusCodes.Status200OK),
e => e.Produces(StatusCodes.Status404NotFound),
e => e.Produces(StatusCodes.Status304NotModified),
e => e.AddEndpointFilter<FluentValidationFilter<CreateOrUpdateBookRequest>>()
];
}
protected override Delegate RequestHandler()
{
return async ([FromRoute] int id, [FromServices] IBookService bookService,
[FromBody] CreateOrUpdateBookRequest dto) =>
{
var result = await bookService.UpdateAsync(id, dto);
return result.Match<IResult>(
entity => TypedResults.Json(data: entity, statusCode: StatusCodes.Status200OK),
err => TypedResults.Json(data: err, statusCode: StatusCodes.Status304NotModified)
);
};
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.AspNetCore.OpenApi (>= 8.0.7)
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 |
|---|