How can I wrap Web API responses(in .net core) for consistency?

后端 未结 4 1542
误落风尘
误落风尘 2020-12-14 18:27

I need to return a consistent response with a similar structure returned for all requests. In the previous .NET web api, I was able to achieve this using DelegatingHandler (

4条回答
  •  孤街浪徒
    2020-12-14 19:18

    For those looking for a modern solution, you can now use AutoWrapper for this.

    It's very easy to use; just add the following to your Startup.cs file:

    app.UseApiResponseAndExceptionWrapper();
    

提交回复
热议问题