Default StatusCodes

What is a good way to set the Reponse.StatusCode for all successful operations, by default?

So for example, if the requestDTO is configured for the verb POST (in the [Route]) then the Response.StatusCode == 201. or perhaps better, if the request DTO is of type IPost then do the same.

Same kinds of defaults for ‘PUT’ and ‘DELETE’ like PUT => 202

Obviously there will be exceptions to the rule, so a developer will have to be able to override this default mechanism in their own operation if they need to.

Is there such a thing out of the box? or is GlobalRequest filter or other mechanism the way to go for this?

(I want to avoid the developer having to remember to write this kind of line every operation: Response.StatusCode = (int)HttpStatusCode.Created and give them a way to override, when they are intentional

You can use a Global Response Filter or a Service Filter to intercept Service responses and modify the response StatusCode.

So if you add the default implementation in OnAfterExecute() in a common base class, they’ll be able to override it with their own impl.