Class: Sidekiq::Mcp::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/mcp/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



9
10
11
12
# File 'lib/sidekiq/mcp/middleware.rb', line 9

def initialize(app)
  @app = app
  @server = Server.new
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/sidekiq/mcp/middleware.rb', line 14

def call(env)
  request = Rack::Request.new(env)
  
  return @app.call(env) unless mcp_request?(request)
  return unauthorized_response unless authorized?(request)
  
  if request.post?
    handle_mcp_request(request)
  else
    method_not_allowed_response
  end
end