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
  • Наука та технологія

КОМЕНТАРІ • 12

  • @CodingTutorialsAreGo
    @CodingTutorialsAreGo  8 місяців тому

    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 👍.

  • @SharafMansour
    @SharafMansour 8 місяців тому +2

    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.

  • @10Totti
    @10Totti 8 місяців тому +3

    Best tutorial!

  • @xucongzhan9151
    @xucongzhan9151 7 місяців тому +1

    Like the content. Would appreciate it if the audio was louder, thx :)

  • @asrarehsan
    @asrarehsan 8 місяців тому +1

    👍👍👍

  • @tomjones984
    @tomjones984 8 місяців тому +2

    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.

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  8 місяців тому +1

      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.

    • @krccmsitp2884
      @krccmsitp2884 8 місяців тому +3

      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.

  • @jaymartinez311
    @jaymartinez311 4 місяці тому +1

    How would structure it if i wanted to extract the callback function and just pass it as ‘MapGet(“/some-route”, SomeCallback)’?

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo  4 місяці тому +1

      That's basically what what's happening in the BookReviewMap class. Or am I misunderstanding the question?

  • @Yemen-Soft
    @Yemen-Soft 8 місяців тому +1

    First ❤