I am trying to serve up static content for some web development, with a few lines of erb to simulate what the real server will do. I already did this with WEBrick here: http://ceronio.net/2011/06/nice-web-server-script-to-server-any-directory-using-webrick, but now I want to do this with Mongrel.
My code so far is like this:
#!/usr/bin/ruby
require 'rubygems'
require 'mongrel'
Mongrel::DirHandler.add_mime_type('.rhtml', 'text/html')
server = Mongrel::HttpServer.new("localhost", 2000)
server.register("/", Mongrel::DirHandler.new(Dir::pwd))
server_thread = server.run
server_thread.join
But when I access my index.rhtml file, it does not process the content in the <% %> tags, but just passes the file as is to the browser.
With WEBrick, nothing additional was required. What do I need to do here to get the server-side Ruby code processed in the .rhtml file?
After looking through the code of the DirHandler class in Mongrel, it seems that this class is not made for applying any processing to a file, but just serving it up as is.
It seems the only way to do this in Mongrel would be to modify DirHandler or write your own HttpHandler.