In my lumen based API, negative responses like entity not found are handled by custom exceptions that are caught by the global exception handler.
Now I'm looking for a non-redundant way to return positive responses.
class ListController extends Controller {
public function someEndpoint(Request $request, Response $response) {
if($bad) {
throw new CustomException("XYZ is bad");
}
/* Instead of */
return response()->json("msgStr" => "Entity created");
/* something like */
return entityCreatedReponse();
}
}
What's the lumen way of defining entityCreatedReponse()? I don't want to have it in a base controller.