Skip to content

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)

Notifications You must be signed in to change notification settings

gurolg/StructuredMinimalApi

 
 

Repository files navigation

Build status Downloads

YaverMinimalApi

The goal of this project it's to show how to use TaskManager.ApiBase package. It demontrate how to configure API endpoints as individual classes based on minimal Api (.Net 6)

Program.cs

Use AddEndpoints extenion method to create each endpoint.

And also MapEndpoint extension method to use new routing APIs

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 interface

public class GetWithParamEndpoint : IEndpoint<string, string>
    {
        public void AddRoute(IEndpointRouteBuilder app)
        {
            app.MapGet("/Todo/2/{param1}", (string param1) => HandleAsync(param1));
        }

        public Task<string> HandleAsync(string request)
        {
            return Task.FromResult($"Hello World! 2 {request}");
        }
    }

Projects Using TaskManager.ApiBase

Nuget Package

A nuget package is available here.

About

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)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 97.2%
  • Dockerfile 2.8%