A few weeks ago I had to develop a PoC which also involved a small backend. I thought this would be a good idea to try Minimal APIs, and based on this experience we would decide whether they are a good fit for us or not.
I think there are plenty of articles and videos about Minimal APIs out there, most of them free, but I wanted something more than a "Hello World!", so I bought this course from Nick Chapsas. In less than one hour I had enough information to start the project and also see what are the best practices when using Minimal APIs. In this course, Nick covered a lot of useful concepts and how to implement them in Minimal APIs, things like:
- Parameter binding
- Configuring services and middleware
- Using a database
- Structuring Minimal APIs
This was enough for me to finish the PoC without wasting time googling for "how to do X with Minimal APIs", everything I needed was there! That being said, I really enjoyed writing my minimal API. I did end up with a Program.cs file that had ~300 lines of code and no unit tests... but in my defense this was just a PoC 😅
Switching to a real-world application
A few days ago we decided that the PoC was a success and we had to rewrite it, but first we had a long discussion about the architecture of the app. One of the points discussed was if we should go along with Minimal APIs or use classic controllers. After a short debate we decided to use classic controllers.
Why we picked classic controllers instead of Minimal APIs?
I initially named this "Lack of features" but it sounded too harsh and it's not really the case. There are still some things missing from Minimal APIs (most of them will come in .NET 7), but you might not need them at all. Nevertheless, I know how it is to be blocked by issues from the platform you're developing on (hello Xamarin.Forms), so I really want to avoid this, that's why this was one of the major reasons we went with classic controllers.
Not a good fit for us
Our API will be big, lots of endpoints and that's why I know for sure I'm not going to put all of this into Program.cs Sure, I can create files with endpoints, but that looks an awful lot like controllers, right? That's why we'll just use classic controllers from the start.
I love Minimal APIs and I think they are great for micro-services, POCs, or serving as a starting point for developers who want to learn ASP.NET. However, for us it wasn't the right fit, so we decided to ditch them in favor of the classic controllers because we want to use the greatest and latest but we also want to be fully featured.