Typically, when we want to have testable application logic, we usually create controller that can looks like this:
[HttpGet]
public IActionResult SomeAction()
{
var result = _someRequestHandler.Handle();
return Ok(result);
}
I think we do it because:
- Controllers are difficult to test
- It's nice to separate logic and controllers
- Controllers could has too many dependencies (fat constructor with multiple Dependency Injections)
But when are using NET 7 minimal API's, then our "controllers method" are just static class. So there are easily testable, but I'm not sure about one thing.
Do you think we should still using something like request handlers? Writing all the logic in a "controller action" seems strange to me, what do you think about it given the known good practices?