Popcorn is a .Net Middleware for your RESTful API that allows your consumers to request exactly as much or as little as they need, with no effort from you.
We offer an 'inspector' option that allows users to intercept a response from a controller and 'wrap' it in some way. Internally, we use this pretty consistently to provide a 'Response' object containing a boolean 'Success' status, object 'Data' property (on success) and strings for ErrorCode, Message, and Details (on error).
It would be convenient for users who are setting up a brand new API to offer a default implementation that does this, as it has many benefits.
Create a class 'ApiResponse' with the properties mentioned above
The Inspector signature used throughout would need to be upgraded to include any thrown exception as well as the result object and the context
ExpandResultAttribute.OnActionExecuted would need to pull any thrown exception from the ActionExecutedContext and pass it to any inspector lambda.
Create a method on PopcornConfiguration called 'UseApiResponse'
This would attach an inspector that captures the result and wraps it in a new ApiResponse with Success = true if no exception was thrown, or Success = false, ErrorCode = (type name of the exception), Message = (Exception message), Details = (Exception.ToString())
We offer an 'inspector' option that allows users to intercept a response from a controller and 'wrap' it in some way. Internally, we use this pretty consistently to provide a 'Response' object containing a boolean 'Success' status, object 'Data' property (on success) and strings for ErrorCode, Message, and Details (on error).
It would be convenient for users who are setting up a brand new API to offer a default implementation that does this, as it has many benefits.