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
andEnableExceptionLogging
options to turn off auto logging. - Added
UnAuthorize
andBadRequest
message forHandleNotSucessAsync()
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:
[Route("{id:long}")]
[HttpGet]
public async Task<IActionResult> Get(long id)
{
var person = await _personManager.GetByIdAsync(id);
if (person != null)
{
return Ok(person);
}
else
return NotFound($"Record with id: { id } does not exist.");
}
Another example such as:
return Unauthorized("Access token is invalid.");
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:
[HttpGet]
[AutoWrapIgnore]
public async Task<IActionResult> Get()
{
var data = await _personManager.GetAllAsync();
return Ok(data);
}
or
[HttpGet]
[AutoWrapIgnore]
public async Task<IEnumerable<Person>> Get()
{
return await _personManager.GetAllAsync();
}
Turn-off Default Logging
You can now turn off Logging by setting EnableResponseLogging
and EnableExceptionLogging
options to false in AutoWrapper
options.
For example:
app.UseApiResponseAndExceptionWrapper(new AutoWrapperOptions {
EnableResponseLogging = false,
EnableExceptionLogging = false
});
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! :)