Class: Thrift::MongrelHTTPServer::Handler
- Inherits:
-
Mongrel::HttpHandler
- Object
- Mongrel::HttpHandler
- Thrift::MongrelHTTPServer::Handler
- Defined in:
- lib/thrift/server/mongrel_http_server.rb
Instance Method Summary collapse
-
#initialize(processor, protocol_factory) ⇒ Handler
constructor
A new instance of Handler.
- #process(request, response) ⇒ Object
Constructor Details
#initialize(processor, protocol_factory) ⇒ Handler
Returns a new instance of Handler.
27 28 29 30 |
# File 'lib/thrift/server/mongrel_http_server.rb', line 27 def initialize(processor, protocol_factory) @processor = processor @protocol_factory = protocol_factory end |
Instance Method Details
#process(request, response) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/thrift/server/mongrel_http_server.rb', line 32 def process(request, response) if request.params["REQUEST_METHOD"] == "POST" response.start(200) do |head, out| head["Content-Type"] = "application/x-thrift" transport = IOStreamTransport.new request.body, out protocol = @protocol_factory.get_protocol transport @processor.process protocol, protocol end else response.start(404) { } end end |