carbond.limiter.ChainLimiter

ChainLimiter should be used to insert series (or tree) of limiters at a given point in the Endpoint tree. A request will be evaluated by each limiter in the chain in order with evaluation stopping at the first limiter that rejects the request.

Class

class carbond.limiter.ChainLimiter()

extends: Limiter

limiters
Array
Description An Array of Limiter instances.
initialize  
Arguments
Description Called on service initialization. Cascades initialization to all limiters managed by this instance.
process  
Arguments
  • req (express.request) – the current Request object
  • res (express.response) – the current Response object
  • next (Function) – continuation
Description Overrides process to iterate over limiters calling process on each individual limiter. If a limiter in the chain ends the request-response cycle, then subsequent limiters will not be evaluated. Similarly, if an error is passed to next, processing will stop and the error will be passed on to the appropriate error handling middleware.

Example