A Month ago, the 3rd version of the RC has been released to test out .NET 5 support. Alot of code refactoring has been done for v5 and there are breaking changes. I would really appreciate if you could test it out as well to better improve this project and to ensure we capture every scenario before rolling out an official v5 release.
AutoWrapper
is a simple, yet customizable global HTTP
exception handler and response wrapper for ASP.NET Core APIs. It uses an ASP.NET Core middleware
to intercept incoming HTTP
requests and automatically wraps the responses for you by providing a consistent response format for both successful and error results. The goal is to let you focus on your business code specific requirements and let the wrapper automatically handle the HTTP
response. This can speedup the development time when building your APIs while enforcing own standards for your HTTP
responses. For more information, see: AutoWrapper on Github.
Breaking changes
- This release only supports .NET 5.
- Middleware has been renamed from
UseApiResponseAndExceptionWrapper
to.UseAutoWrapper
. Make sure to update yourStartup.cs
to use the new name. ProblemDetails
is now the default exception format.UseApiProblemDetailsException
has been renamed toDisableProblemDetailsException
.- Removed
Newtonsoft.Json
dependency and replaced it withSystem.Text.Json
. - Use the interface
IApiResponse
model instead of the concreteApiResponse
. model for returning responses using the default format. This allows you to add your own properties that will wrapped within theResult
property. AutoWrapIgnore
andRequestDataLogIgnore
attributes now leaves underAutoWrapper.Attributes
namespace. The implementation was changed from usingIActionFilter
to useAttribute
, eliminating all the request header logic.
The following options has been removed:
- ApiVersion
- ReferenceLoopHandling
- UseCustomSchema
ReferenceLoopHandling
andDefaultContractResolver
aren't still supported.
Installation
- Download and Install the latest
AutoWrapper.Core
from NuGet or via CLI:
PM> Install-Package AutoWrapper.Core -Version 5.0.0-rc-03
- Declare the following namespace within
Startup.cs
using AutoWrapper;
- Register the
middleware
below within theConfigure()
method ofStartup.cs
"before" theUseRouting()
middleware
:
app.UseAutoWrapper();
That's simple! Please provide feedback if there are any issues you encountered. Thank you!