Class: RosettAi::Mcp::Middleware::ContentType
- Inherits:
-
Object
- Object
- RosettAi::Mcp::Middleware::ContentType
- 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.
Instance Method Summary collapse
-
#call(env) ⇒ Array
Rack response triplet.
-
#initialize(app) ⇒ ContentType
constructor
A new instance of ContentType.
Constructor Details
#initialize(app) ⇒ ContentType
Returns a new instance of ContentType.
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.
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 |