Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1001 Bytes

File metadata and controls

54 lines (40 loc) · 1001 Bytes

4. API Features

Essential features for building production-ready APIs.

Chapters

  1. OpenAPI / Swagger - Auto-generated documentation
  2. Rate Limiting - Request throttling
  3. CORS - Cross-origin resource sharing
  4. Response Caching - Cache headers & strategies
  5. Health Checks - Monitoring endpoints

Quick Examples

Swagger

App.UseSwagger;
App.UseSwaggerUI;
// Visit: /swagger

Rate Limiting

App.UseRateLimiting(
  TRateLimitOptions.Create
    .Limit(100)
    .PerMinute
);

CORS

App.UseCors(
  TCorsOptions.Create
    .AllowOrigin('https://myapp.com')
    .AllowMethods(['GET', 'POST'])
);

Health Check

App.MapGet('/health', procedure(Ctx: IHttpContext)
  begin
    Ctx.Response.Json('{"status": "healthy"}');
  end);

← Authentication | Next: OpenAPI/Swagger →