Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/michelcedric/StructuredMinimalApi
The goal of this project it's to show how to use MinimalApi.Endpoint package. It demontrate how to configure API endpoints as individual classes based on minimal Api (.Net 6)
https://github.com/michelcedric/StructuredMinimalApi
api csharp dotnet minimal-api minimalapi
Last synced: 5 days ago
JSON representation
The goal of this project it's to show how to use MinimalApi.Endpoint package. It demontrate how to configure API endpoints as individual classes based on minimal Api (.Net 6)
- Host: GitHub
- URL: https://github.com/michelcedric/StructuredMinimalApi
- Owner: michelcedric
- Created: 2021-12-29T16:02:51.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-21T22:01:06.000Z (over 1 year ago)
- Last Synced: 2024-08-31T11:15:19.757Z (2 months ago)
- Topics: api, csharp, dotnet, minimal-api, minimalapi
- Language: C#
- Homepage:
- Size: 56.6 KB
- Stars: 85
- Watchers: 5
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Build status](https://github.com/michelcedric/StructuredMinimalApi/actions/workflows/dotnet.yml/badge.svg)](https://github.com/michelcedric/StructuredMinimalApi/actions/workflows/dotnet.yml)
[![Downloads](https://img.shields.io/nuget/dt/MinimalApi.Endpoint?color=blue&label=Downloads&logo=nuget)](https://www.nuget.org/packages/MinimalApi.Endpoint)
# StructuredMinimalApi
The goal of this project it's to show how to use MinimalApi.Endpoint package.
It demontrate how to configure API endpoints as individual classes based on minimal Api (.Net 6)## Program.cs
Use [AddEndpoints](https://github.com/michelcedric/StructuredMinimalApi/blob/master/MinimalApi.Endpoint/Extensions/IServiceCollectionExtensions.cs#L7) extenion method to create each endpoint.And also [MapEndpoint](https://github.com/michelcedric/StructuredMinimalApi/blob/master/MinimalApi.Endpoint/Extensions/IEndpointRouteBuilderExtensions.cs#L8) extension method to use new routing APIs
```csharp
var builder = WebApplication.CreateBuilder(args);builder.Services.AddEndpoints();
var app = builder.Build();
app.MapEndpoints();
app.Run();
```## Define an endpoint
To create and define one endpoint, it needs to implement [IEndpoint](https://github.com/michelcedric/StructuredMinimalApi/blob/master/MinimalApi.Endpoint/IEndpoint.cs) interface```csharp
public class GetWithParamEndpoint : IEndpoint
{
public void AddRoute(IEndpointRouteBuilder app)
{
app.MapGet("/Todo/2/{param1}", (string param1) => HandleAsync(param1));
}public Task HandleAsync(string request)
{
return Task.FromResult($"Hello World! 2 {request}");
}
}
```## Projects Using MinimalApi.Endpoint
- [eShopOnWeb](https://github.com/dotnet-architecture/eShopOnWeb): Sample ASP.NET Core reference application, powered by Microsoft
- [Use in PublicApi project](https://github.com/dotnet-architecture/eShopOnWeb/tree/main/src/PublicApi): This project demonstrates how to configure endpoints as individual classes- [EshopOnVue.js](https://github.com/michelcedric/EshopOnVue.js): Same as EshopOnWeb project in Vue.js
- [StructuredMinimalApi](https://github.com/michelcedric/StructuredMinimalApi/tree/master/StructuredMinimalApi): Sample project to show some usage
- [WebApiBestPractices](https://github.com/ardalis/WebApiBestPractices): Resources related to Ardalis Pluralsight course on this topic.
- [Pluralsight : ASP.NET Core 6 Web API: Best Practices](https://www.pluralsight.com/courses/aspdotnet-core-6-web-api-best-practices): Organizing Minimal API demo and best practices.## Nuget Package
A nuget package is available [here](https://www.nuget.org/packages/MinimalApi.Endpoint/).