Throttle to URL in node.js restore

The documentation states:

Note that you can always put this for routes by URL to include different request rates for different resources (if, for example, one route, for example / my / slow / database, is much simpler than / My / fast / cache) .

I'm having problems with how to accurately implement this.

Basically, I want to serve static files with a different throttle speed than my API.

+8
restify
source share
1 answer

Throttle setting (speed limiter) with update for some endpoints, such as.

var rateLimit = restify.throttle({burst:100,rate:50,ip:true}); server.get('/my/endpoint', rateLimit, function(req, res, next) { // Do something here return next(); } ); server.post('/another/endpoint', rateLimit, function(req, res, next) { // Do something here return next(); } ); 

Or like that.

  server.post('/my/endpoint', restify.throttle({burst:100,rate:50,ip:true}), function(req, res, next) { // Do something here return next(); } ); 

Even when throttling to an endpoint, a global throttle may be required, so this can be done as follows.

  server.use(restify.throttle({burst:100,rate:50,ip:true}); 

(link) Throttle is one way to validate Bundled-Plugins .

+11
source share

All Articles