AutoWrapper Version 2.1.0 Released!

A simple, yet customizable global exception handler and response wrapper for ASP.NET Core APIs.

Today,  AutoWrapper 2.1.0 has been released with newly features added based on community feedback. Here are the newly features added:
  • Added [AutoWrapIgnore] action filter attribute.
  • Added support to override non-success message when using IActionResult return types.
  • Added EnableResponseLogging and EnableExceptionLogging options to turn off auto logging.
  • Added UnAuthorize and BadRequest message for HandleNotSucessAsync() method response.
 

Using IActionResult Return Types

AutoWrapper now supports IActionResult return types that allows you to return non successful requests such as BadRequest, NotFound, UnAuthorize and etc.
For example:
 
  1. [Route("{id:long}")]  
  2. [HttpGet]  
  3. public async Task<IActionResult> Get(long id)    
  4. {  
  5.     var person = await _personManager.GetByIdAsync(id);  
  6.     if (person != null)  
  7.     {  
  8.         return Ok(person);  
  9.     }  
  10.     else  
  11.         return NotFound($"Record with id: { id } does not exist.");  
  12. }  
Another example such as:
 
  1. return Unauthorized("Access token is invalid.");    
  2. return BadRequest("SomeField is null.");    

AutoWrapIgnore Attribute

You can now use the [AutoWrapIgnore] filter attribute for enpoints that you don't want to be wrapped.
For example:
 
  1. [HttpGet]  
  2. [AutoWrapIgnore]  
  3. public async Task<IActionResult> Get()    
  4. {  
  5.     var data = await _personManager.GetAllAsync();  
  6.     return Ok(data);  
  7. }  
 
 
or 
 
  1. [HttpGet]  
  2. [AutoWrapIgnore]  
  3. public async Task<IEnumerable<Person>> Get()    
  4. {  
  5.     return await _personManager.GetAllAsync();  
  6. }  
 

Turn-off Default Logging

You can now turn off Logging by setting EnableResponseLogging and EnableExceptionLogging options to false in AutoWrapper options.
For example:
 
  1. app.UseApiResponseAndExceptionWrapper(new AutoWrapperOptions {    
  2.               EnableResponseLogging = false,   
  3.               EnableExceptionLogging = false   
  4. });  
 
That's it. Feel free to request an issue on github if you find bugs or request a new feature. Your valuable feedback is much appreciated to better improve this project. If you find this useful, please give it a star to show your support for this project.
Thank you all! :)