Minimal APIs khai báo HTTP endpoint trực tiếp trong Program.cs mà không cần class controller: app.MapPost("/users", handler).
- Phù hợp cho microservice nhỏ, REST API đơn giản vì ít boilerplate. .NET 8 cung cấp Minimal APIs tương thích AOT.
- Giới hạn: ít cấu trúc hơn cho ứng dụng phức tạp.
- Controller vẫn phù hợp cho ứng dụng lớn, nhiều tính năng.
- Nên chọn Minimal APIs khi cần khởi tạo nhanh, độ phức tạp thấp.
Minimal APIs declare HTTP endpoints directly in Program.cs without controller classes: app.MapPost("/users", handler).
- They reduce boilerplate for simple CRUD and microservice scenarios. .NET 8 provides AOT-compatible minimal APIs.
- Trade-off: less structure for complex applications.
- Controllers remain preferable for large, feature-rich apps.
- Choose Minimal APIs for rapid startup and low-complexity scenarios.