Skip to content

Support for nested WebApiEndpoints

Allows you to structure your project how you want to, not restricted to top level classes like MVC. Supports:

  • Nested classes
  • Static classes
  • Multiple assemblies

Nested classes

All types in an assembly are inspected, not just top-level Controllers like Mvc Controllers.

Static classes

public static class BlogGet
{
    public class ApiEndpoint : QueryWebApiEndpoint.NoRequest.ResponseDataCollection<ApiEndpoint, BlogDto, Blog>
    {
        private readonly IBlogStorageBroker _storageBroker;

        public ApiEndpoint(IBlogStorageBroker storageBroker)
        {
            _storageBroker = storageBroker;
        }

        public override Task<Result<ResponseDataCollection<Blog>>> ExecuteAsync(RequestEmpty , CancellationToken cancellationToken) =>
            _storageBroker.GetAsync()
                          .ToResponseDataCollectionAsync();
    }
}

Multiple assemblies

Register all the assemblies that contain WebApiEndpoints during the application startup.

containerBuilder.RegisterModule(new WebApiEndpointModule(typeof(AssemblyHook).Assembly));