DiegoG.REST.ASPNET
1.1.1
dotnet add package DiegoG.REST.ASPNET --version 1.1.1
NuGet\Install-Package DiegoG.REST.ASPNET -Version 1.1.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="DiegoG.REST.ASPNET" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DiegoG.REST.ASPNET --version 1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DiegoG.REST.ASPNET, 1.1.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 DiegoG.REST.ASPNET as a Cake Addin #addin nuget:?package=DiegoG.REST.ASPNET&version=1.1.1 // Install DiegoG.REST.ASPNET as a Cake Tool #tool nuget:?package=DiegoG.REST.ASPNET&version=1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DiegoG.REST.ASPNET
Adds extension methods, attribute action filters and middleware to register services, validations and catch both action exceptions and model validation errors to ensure the API always returns standardized responses in any eventuality
Examples
public static Task Main(string[] args)
{
// .... Other service setup code
// Registers a serializer service for responses of ResponseCode
builder.Services.AddRESTObjectSerializer(new JsonRESTSerializer<ResponseCode>());
// Registers the Type table for responses of ResponseCode
builder.Services.AddRESTObjectTypeTable(RESTResponseTypeTable.Instance);
// Registers the service for RESTObject validation, to permit the usage of `ValidateRESTObjectAttribute` in controllers and actions
builder.Services.UseRESTObjectValidationFilter<ResponseCode>();
// Registers a response factory for model validation errors
builder.Services.UseRESTInvalidModelStateResponse(
(c, e) => new RESTObjectResult<ResponseCode>(new ErrorResponse(e))
{
StatusCode = (int)HttpStatusCode.BadRequest
}
);
// .... Other service setup code
var app = builder.Build();
// Registers Middleware to handle action exceptions
app.UseRESTExceptionHandler(
(r, e, serv, con) => Task.FromResult<ExceptionRESTResponse<ResponseCode>>(
new(
new ErrorResponse(e),
HttpStatusCode.InternalServerError
)
)
);
// .... Other app setup code
}
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- DiegoG.REST.Core (>= 1.0.1)
- Microsoft.AspNetCore (>= 2.2.0)
- Microsoft.AspNetCore.Mvc.Core (>= 2.2.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.