Class: ThriftRack::FormatCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/thrift_rack/format_check.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ FormatCheck

Returns a new instance of FormatCheck.



3
4
5
# File 'lib/thrift_rack/format_check.rb', line 3

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
# File 'lib/thrift_rack/format_check.rb', line 7

def call(env)
  req = Rack::Request.new(env)
  return Rack::Response.new(["Not Valid Thrift Request"], 400, {'Content-Type' => 'text/plain'}) unless req.post? && req.env["CONTENT_TYPE"] == THRIFT_HEADER
  @app.call(env)
end