Search Results for

    Show / Hide Table of Contents

    Using IEndpointDefinition

    You can define your own minimal api endpoint definition by implementing the IEndpointDefintion interface.

    internal class MyEndpointsDefinition : IEndpointDefinition
    {
      public void MapEndpoints(WebApplication app) 
      {
        app.MapGet("/helloworld", HelloWorldEndpoint);
      }
    
      private Task<IResult> HelloWorldEndpoint()
      {
        return Task.FromResult(Results.Ok());
      }
    }
    

    Add your endpoint definition

    builder.Services.AddEndpointDefinition<MyEndpointDefinition>(); // <--
    
    var app = builder.Build();
    
    ...
    
    app.UseAuthentication();
    app.UseAuthorization();
    
    ...
    
    app.MapEndpoints(); // <--
    
    app.Run();
    
    • Improve this Doc
    In This Article
    Back to top Developed by MadeY and contributors / Licensed under MIT / Website generated by DocFX