If you are a fan of Minimal API in .NET then read on 👇
Minimal API made API creation easier than ever.
From .NET 6 version, APIs can be created in just a few lines of code that work the same if created in a controller-based way.
But there was no possibility to group similar endpoints like in a controller-based approach with [Route] attribute. and the only way was to add prefixes for every endpoint.
Then in .NET 7, endpoint grouping came allowing endpoints to be grouped with a prefix like with [Route], thus reducing repetitive code and making it easier to customize entire groups of them.
To create a group, add a variable that will hold the result of the MapGroup method, which takes a prefix as a parameter. Newly created endpoints that are append to a variable will contain a prefix along with the route value from an endpoint if it exists.
#csharp #dotnet
#restapi #softwaredevelopment
Minimal API made API creation easier than ever.
From .NET 6 version, APIs can be created in just a few lines of code that work the same if created in a controller-based way.
But there was no possibility to group similar endpoints like in a controller-based approach with [Route] attribute. and the only way was to add prefixes for every endpoint.
Then in .NET 7, endpoint grouping came allowing endpoints to be grouped with a prefix like with [Route], thus reducing repetitive code and making it easier to customize entire groups of them.
To create a group, add a variable that will hold the result of the MapGroup method, which takes a prefix as a parameter. Newly created endpoints that are append to a variable will contain a prefix along with the route value from an endpoint if it exists.
#csharp #dotnet
#restapi #softwaredevelopment