← All compilation units

Flyology.HTTP.Server.Middleware_Rate_Limits

Description

Enforces bounded per-client, per-route token buckets.

App_Context

type App_Context is limited private;

Call

procedure Call
  (Context : in out App_Context;
   X       : in out Flyology.HTTP.Server.Applications.Exchange;
   Next    : in out Components.Next_Handler)

Token-bucket middleware. Burst capacity equals the configured route requests-per-second rate. Rejection is 429 with Retry-After.

Parameters
Context

Typed application context

X

Borrowed request exchange

Next

Borrowed downstream continuation

Capacity

Capacity : Positive := 1_024;

Client_Key

function Client_Key
(X : Flyology.HTTP.Server.Applications.Exchange) return String
Parameters
X
Return value

Clock

function Clock return Ada.Real_Time.Time
Return value

Components

with package Components is new
  Flyology.HTTP.Server.Middleware (App_Context);

Metric_Output

Metric_Output : access Metrics.Sink'Class := null;