A java servlet filter that implements the rack interface for calling ruby web applications
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Rack Interface Filter is a simple filter that can be deployed to a servlet container. On startup, the filter 
instantiates a JRuby instance, bootstraps a ruby web framework, then instantiates a rack adaptor for that framework.
When an request comes in, the filter translates the request to a RubyHash and passes it to the rack adaptor's call method.

This is very much a work in progress, and the only framework with which it has been used is Merb. There is currently no
support for bundling up a ruby web application as a war file, though it shouldn't be hard to add.

To test this with a merb application, add a WEB-INF directory to the public directory:


Sample web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <display-name>Rack Test</display-name>


To test this with tomcat, create the file


<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="/path/to/merb/app/public" path="" />

From here, you should have the merb app deployed to the root of the server (though it should be possible to map it to 
some other url).

Start up tomcat, and try to hit the app.

The placement of WEB-INF, the general assumptions about directory layouts, and war packaging are all fluctuating at the moment. This layout seemed like the quickest way to get a test with Merb running.

There are a few issues already. For one, sometimes the rack adaptor is returning a <File> object as the third element
in the response tuple. I'm not sure what to do about that yet. If strings are returned, everything works. As a workaround
for that, you can specify ignore paths ("/images", "/stylesheets", "/javascript", "/favicon.ico" by default). If a reuest
is made for a url that starts with an ignore path, it's passed to the servlet container's default servlet. Right now, this is just passing through requests for static content. My guess is that the default servlet is better at handling static content anyway,
but this behavior might have to change. You could also use the ignore path to allow requests to flow through to other servlets or
filters to stack ruby web apps or regular java servlets.

As a disclaimer, I clearly have no idea what I'm doing. Any help or suggestions would be great.