Return status from domain

In our domain application, we use a type called ServiceResponse<> to send data between the levels of our application - in particular, each is returned to all methods in the domain. At the moment, it encapsulates the data (if any) that was returned from the method, or any errors that it could generate.

So my question is this: is it acceptable to apply fields to this object that can be useful in other layers of the application? For example, is it a good form to add a Status or StatusCode field to it, which can be interpreted later by the service layer for use as an HTTP status code (with or without any display)?

+4
source share
1 answer

It sounds like a great place for me. The idea that each method returns a โ€œresponseโ€ of some odor is a bit like trying to separate too much, but there are cases where such an extreme outcome is justified.

In any case, ServiceResponse can easily have a status, and if you need one, I have to put it.

+1
source

Source: https://habr.com/ru/post/1392141/


All Articles