ProudMonkey

AutoWrapper 4.1.0 Released!

This space is for rent. Contact me at vmsdurano at gmail dot com.

AutoWrapper reached 14k downloads and 166 stars today. Big thanks to everyone who have supported it! I truly appreciate it. :)

Today, AutoWrapper 4.1.0 has been released with newly features added based on community feedback. Here are the newly features added:

  • [NEW] Added RequestDataLogIgnore Attribute. This addresses issue #37.
  • [NEW] Added ShouldLogRequestData property in AutoWrapIgnore Attribute. This addresses issue #37 as well.
  • [NEW] Added LogRequestDataOnException Option.
  • [NEW] Added BypassHTMLValidation check when IsApiOnly is true. This addresses issue #41.
  • [RFT] Code Cleanup and Refactoring.

Samples

You can use the [RequestDataLogIgnore] if you don't want certain endpoints to log the data in the requests:

[HttpGet]
[RequestDataLogIgnore]
public async Task<ApiResponse> Post([FromBody] CreatePersonRequest personRequest)  
{
    if (!ModelState.IsValid)
    {
        throw new ApiException(ModelState.AllErrors());
    }

    return new ApiResponse("Record successfully created.", 
                            await _repo.CreateAsync(personRequest), 
                            Status201Created);
}

You can use the [AutoWrapIgnore] attribute and set ShouldLogRequestData property to false if you have an endpoint that don't need to be wrapped and also don't want to log the data in the requests:

[HttpGet]
[AutoWrapIgnore(ShouldLogRequestData = false)]
public async Task<IEnumerable<PersonResponse>> Get()  
{
     // Rest of the code here
}

You can set the LogRequestDataOnException option to false if you want to exclude the request body data in the logs when an exception occurs.

app.UseApiResponseAndExceptionWrapper(new AutoWrapperOptions {  
    LogRequestDataOnException = false 
});

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 on this project!

Buy Me A Coffee