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. Ifnext
is present in the argument list,fn
will be responsible for calling next. Otherwise, thefn
should returntrue
to indicate that processing should continue orfalse
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 currentRequest
object - res (
express.response
) – the currentResponse
object - next (
Function
) – continuation
Description This wraps fn
, catches any errors it may throw, and callsnext
if appropriate.- req (