VMD.RESTApiResponseWrapper.Net
1.0.0
A REST global exception handler and response wrapper for Web API written in Full .NET Framework
See the version list below for details.
Install-Package VMD.RESTApiResponseWrapper.Net -Version 1.0.0
dotnet add package VMD.RESTApiResponseWrapper.Net --version 1.0.0
<PackageReference Include="VMD.RESTApiResponseWrapper.Net" Version="1.0.0" />
paket add VMD.RESTApiResponseWrapper.Net --version 1.0.0
#r "nuget: VMD.RESTApiResponseWrapper.Net, 1.0.0"
STEPS to use the RESTApiResponseWrapper.Net
- Declare the following namespace within WebApiConfig.cs
using VMD.RESTApiResponseWrapper.Net;
using VMD.RESTApiResponseWrapper.Net.Filters;
- Register the following within WebApiConfig.cs
config.Filters.Add(new ApiExceptionFilter());
config.MessageHandlers.Add(new WrappingHandler());
- Done.
To use the Custom API Exception, you could do:
throw new ApiException("Your Message",401, ModelStateExtension.AllErrors(ModelState));
The ApiException has the following parameters:
ApiException(string message,
int statusCode = 500,
IEnumerable<ValidationError> errors = null,
string errorCode = "",
string refLink = "")
For ASP.NET Core Folks
You can try download the .NET Core version of this wrapper at https://www.nuget.org/packages/VMD.RESTApiResponseWrapper.Core/
STEPS to use the RESTApiResponseWrapper.Net
- Declare the following namespace within WebApiConfig.cs
using VMD.RESTApiResponseWrapper.Net;
using VMD.RESTApiResponseWrapper.Net.Filters;
- Register the following within WebApiConfig.cs
config.Filters.Add(new ApiExceptionFilter());
config.MessageHandlers.Add(new WrappingHandler());
- Done.
To use the Custom API Exception, you could do:
throw new ApiException("Your Message",401, ModelStateExtension.AllErrors(ModelState));
The ApiException has the following parameters:
ApiException(string message,
int statusCode = 500,
IEnumerable<ValidationError> errors = null,
string errorCode = "",
string refLink = "")
For ASP.NET Core Folks
You can try download the .NET Core version of this wrapper at https://www.nuget.org/packages/VMD.RESTApiResponseWrapper.Core/
Release Notes
Initial release
Dependencies
-
- Microsoft.AspNet.WebApi.Client (>= 5.2.4)
- Microsoft.AspNet.WebApi.Core (>= 5.2.4)
- Newtonsoft.Json (>= 11.0.2)
Used By
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.