carbond.limiter.FunctionLimiter

FunctionLimiter is the most basic limiter class. Simply define fn and return true to allow further processing of the request and false to end processing.

NOTE: fn is responsible for ending the request-response cycle if processing is to stop. This can be accomplished by calling express.request.end (explicitly or implicitly via send, render, or json) or by using the helper method sendUnavailable.

Class

class carbond.limiter.FunctionLimiter()

extends: Limiter

fn
Function
Description This function should either take the arguments (req, res) or (req, res, next). Note that these are the same arguments passed to a standard express middleware function. If next is present in the argument list, fn will be responsible for calling next. Otherwise, the fn should return true to indicate that processing should continue or false to stop processing. In either case, fn is responsible for ending the request-response cycle if processing is to stop.
process  
Arguments
  • req (express.request) – the current Request object
  • res (express.response) – the current Response object
  • next (Function) – continuation
Description This wraps fn, catches any errors it may throw, and calls next if appropriate.

Example