mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-03-27 00:57:47 -04:00
(P4DEVOPS-9434) Wire RateLimiter middleware into API Rack stack
This commit is contained in:
parent
2d4eec1f85
commit
dfb2a384ab
1 changed files with 6 additions and 1 deletions
|
|
@ -3,7 +3,7 @@
|
|||
module Vmpooler
|
||||
class API < Sinatra::Base
|
||||
# Load API components
|
||||
%w[helpers dashboard v3 request_logger healthcheck].each do |lib|
|
||||
%w[helpers dashboard v3 request_logger healthcheck rate_limiter].each do |lib|
|
||||
require "vmpooler/api/#{lib}"
|
||||
end
|
||||
# Load dashboard components
|
||||
|
|
@ -50,6 +50,11 @@ module Vmpooler
|
|||
# Enable API request logging only if required
|
||||
use Vmpooler::API::RequestLogger, logger: logger if config[:config]['request_logger']
|
||||
|
||||
# Enable rate limiting if configured
|
||||
if config[:config]['rate_limiting_enabled']
|
||||
use Vmpooler::API::RateLimiter, redis, config
|
||||
end
|
||||
|
||||
use Vmpooler::Dashboard
|
||||
use Vmpooler::API::Dashboard
|
||||
use Vmpooler::API::V3
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue