Class: RosettAi::Mcp::Middleware::ContentType

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

Overview

Rack middleware that enforces application/json on POST requests.

Returns 415 Unsupported Media Type for non-JSON POST bodies.

Author:

  • hugo

  • claude

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ ContentType

Returns a new instance of ContentType.

Parameters:

  • app (#call)

    the next Rack application



17
18
19
# File 'lib/rosett_ai/mcp/middleware/content_type.rb', line 17

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Array

Returns Rack response triplet.

Parameters:

  • env (Hash)

    Rack environment

Returns:

  • (Array)

    Rack response triplet



23
24
25
26
27
28
# File 'lib/rosett_ai/mcp/middleware/content_type.rb', line 23

def call(env)
  return @app.call(env) unless post_request?(env)
  return @app.call(env) if json_content_type?(env)

  unsupported_media_type(env)
end