REST API
The Web module generates Minimal API endpoints from your Dispatch handlers — commands, queries, and auth flows — with a single [RestApi] attribute. No controllers, no manual route registration, no boilerplate.
Quick Start
[Runtime]
public partial class CatalogRuntime;
[DispatchModule]
public static partial class CatalogDispatch;
[RestApi(RoutePrefix = "/api/catalog", Title = "eShop Catalog API")]
public partial class CatalogApp;
public sealed record GetCatalogItemById(CatalogItemId Id) : IQuery;
public static class GetCatalogItemByIdHandler
{
[QueryHandler, HttpGet("/items/{id}")]
public static Eff<CatalogRuntime, Option<CatalogItem>> Handle(GetCatalogItemById query) =>
CatalogStore.CatalogItems.GetById<CatalogRuntime>(query.Id);
}
This generates:
AddCatalogApp() — DI registration with JSON, CORS, OpenAPI, health checks
MapCatalogApp() — maps all HTTP-annotated handlers as Minimal API endpoints
- TypeScript client — typed
fetch wrapper (opt-in)
var builder = WebApplication.CreateBuilder(args);
builder.AddCatalogRuntime();
builder.Services.AddCatalogApp();
var app = builder.Build();
app.MapCatalogApp();
app.Run();
Features
| Feature |
Description |
| Endpoint generation |
[HttpGet], [HttpPost], [HttpPut], [HttpPatch], [HttpDelete] on handlers |
| Auth endpoints |
[WebAuth("google")] generates login, refresh, logout |
| Access control |
[Public] for unauthenticated, [Authorize] for policy-based |
| OpenAPI |
Swagger docs enabled by default |
| TypeScript client |
Typed request/response interfaces and fetch wrapper |
| CORS |
WithCorsOrigins(...) fluent configuration |
| Azure Functions |
[AzureFunctionsApi] generates Isolated Worker endpoints from dispatch handlers |
| Webhooks |
[Webhook<TValidator>] validates inbound webhook signatures before handler execution |
| HTTP Method |
Default Status |
Use Case |
HttpGet |
200 OK |
Queries |
HttpPost |
201 Created |
Create commands |
HttpPut |
204 No Content |
Full updates |
HttpPatch |
200 OK |
Partial updates |
HttpDelete |
204 No Content |
Deletions |
What's Next
| Page |
Description |
| Attribute Reference |
[RestApi], [HttpGet], [HttpPost], [Public], [WebAuth], [AzureFunctionsApi], [Webhook<T>] |
| Generated Code |
Endpoint mappings, bootstrap extensions, auth endpoints, TypeScript output |