ASP.NET Minimal API Structure
Вставка
- Опубліковано 12 жов 2023
- Minimal APIs allow you to define your entire web service in Program.cs. But that's not ideal for maintainability. Here's how to structure your application.
Source code available at: github.com/JasperKent/Control...
Topics include:
- Creating a Minimal API application
- Adding GET, POST, PUT and DELETE endpoints
- Injecting services
- Using TypedResults
- Separating endpoint functions into a separate file
- Converting controller action methods to endpoints
- Naming routes
- Separating endpoint mapping code to a separate file
- Scaffolding endpoints - Наука та технологія
Do you structure your Minimal API apps, or just dump everything in Program. Leave a comment and let me know.
Source code available at: github.com/JasperKent/Controller-vs-Minimal-APIs
Remember to subscribe at ua-cam.com/channels/qWQzlUDdllnLmtgfSgYTCA.html
And if you liked the video, click the 👍.
Amazing and Insightful video. Can not wait for all the upcoming videos about the new features in C# 12 and Dotnet 8.0/ AspNetCore 8.0. Been a huge fan since your video about Records in C# 8.
Best tutorial!
Like the content. Would appreciate it if the audio was louder, thx :)
👍👍👍
Great explanation and presentation, the one thing which put me off looking into minimal APIs was the untidiness of the code shown in all the examples I saw.
However, the additional files, ensuring they're all properly mapped, along with the new classes, interfaces and return values has brought me back to my original concern - what's the point? It seems like more effort and code to achieve the same result as a traditional controller.
I've not seen your performance-related videos yet, so perhaps the "minimal" intent is purely resource-based, rather than from a software developer's point of view.
Once things get complicated, I'd say the only real advantage is performance, which is slight. That said, I think Minimal APIs are easier to learn for a newcomer - more similar to Python and Node.js.
Well, you have the option to make it as complex as controllers, but you don't have to. In fact, you are way more flexible in organizing your endpoints. And without the MVC-ish controller ceremony, Minimal APIs make more sense for API-only backends.
How would structure it if i wanted to extract the callback function and just pass it as ‘MapGet(“/some-route”, SomeCallback)’?
That's basically what what's happening in the BookReviewMap class. Or am I misunderstanding the question?
First ❤