No commit activity in last 3 years
No release in over 3 years
Rack middleware for thrift services
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 2.14.0

Runtime

>= 1.1.0
>= 0.9.0
 Project Readme

thrift-rack-middleware

A simple rack middleware that can intercept HTTP thrift requests.

This is useful when used in combination with a pooled application server like passenger. It is not an easy task to have thrift directly target worker processes that application servers like passenger manage.

Accessing the handler applications via thrift this was may not be the fastest, but it is one of the easier ways to get started.

Usage

If you want to add this middleware to a Rails application, add the following to your config/application.rb

handler = ThriftHandler.new
processor = MyThrift::Processor.new(handler)
config.middleware.use Thrift::RackMiddleware,
                      processor: processor,
                      hook_path: '/thrift_rpc',
                      protocol_factory: Thrift::BinaryProtocolAcceleratedFactory.new

Defaults

  • hook_path defaults to '/rpc_api'
  • protocol_factory defaults to Thrift::BinaryProtocolFactory.new
  • logger see logging section below

Logging

You can optionally pass in a custom logger instance. If your application is a Rails application, Rails.logger will automatically be used. If your application is a Rack application, rack logger will automatically be used. Otherwise, logging will be directed to STDOUT

Future features

  • Add a way to pass in a lambda or other means to insert authentication logic into the middleware.
  • Add PIDs to the logs

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request