Do you use Minimal APIs over Controllers?

Updated by Brady Stroud [SSW] 1 year ago. See history

123
No component provided for introEmbed
[ApiController]
[Route("[controller]")]
public class HelloWorldController : ControllerBase
{
[HttpGet]
public IActionResult Get()
{
return Ok("Hello World!");
}
}

❌ Figure: Figure: Bad Example - 9 lines of code for a simple endpoint

app.MapGet("/", () => "Hello World!");

✅ Figure: Figure: Good Example - 1 line of code for a simple endpoint

Minimal APIs are great for

  • Learning
  • Quick prototypes
  • Vertical Slice Architecture
  • A similar developer experience to NodeJS
  • Performance

Acknowledgements

Daniel Mackay
William Liebenberg
Brady Stroud
Related rules

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star