Code Review: ironruby-rack

http://github.com/jschementi/ironruby/tree/f57b6adec5fcb2896ed850683c0b1fd39ded23f0/Merlin/Main/Hosts/IronRuby.Rack

ironruby-rack: Run Rack-based web applications on IIS with IronRuby
What it is:
http://blog.jimmy.schementi.com/2009/05/ironruby-at-railsconf-2009.html#iis

Uses ASP.NET’s HttpHandlers to:

· Registering IronRuby.Rack in the Rack-based application’s
Web.confighttp://github.com/jschementi/ironruby/blob/92932a672921a03210c8aefe23ac0a7d6996ed2d/Merlin/Main/Hosts/IronRuby.Rack/IronRuby.Rack.Example/Web.config

· Load a Rackhttp://rack.rubyforge.org/-based application on
startup
(HttpHandlerFactoryhttp://github.com/jschementi/ironruby/blob/92932a672921a03210c8aefe23ac0a7d6996ed2d/Merlin/Main/Hosts/IronRuby.Rack/HttpHandlerFactory.cs
and
Applicationhttp://github.com/jschementi/ironruby/blob/92932a672921a03210c8aefe23ac0a7d6996ed2d/Merlin/Main/Hosts/IronRuby.Rack/Application.cs
constructor).

o Initializes Rack and runs the application’s
config.ruhttp://github.com/jschementi/ironruby/blob/92932a672921a03210c8aefe23ac0a7d6996ed2d/Merlin/Main/Hosts/IronRuby.Rack/IronRuby.Rack.Example/config.ru,
which tells Rack what application (any Ruby object that responds to
“call”)

· Intercept web requests
(HttpHandler.ProcessRequesthttp://github.com/jschementi/ironruby/blob/92932a672921a03210c8aefe23ac0a7d6996ed2d/Merlin/Main/Hosts/IronRuby.Rack/HttpHandler.cs)

o Creates a
Requesthttp://github.com/jschementi/ironruby/blob/92932a672921a03210c8aefe23ac0a7d6996ed2d/Merlin/Main/Hosts/IronRuby.Rack/Request.cs
and a
Responsehttp://github.com/jschementi/ironruby/blob/92932a672921a03210c8aefe23ac0a7d6996ed2d/Merlin/Main/Hosts/IronRuby.Rack/Response.cs,
and passes it off to
IIS.Handlehttp://github.com/jschementi/ironruby/blob/92932a672921a03210c8aefe23ac0a7d6996ed2d/Merlin/Main/Hosts/IronRuby.Rack/IIS.cs#L31
which:

§ Set up the environment according to the Rack
specificationhttp://rack.rubyforge.org/doc/SPEC.html

§ Calls
Application.Callhttp://github.com/jschementi/ironruby/blob/92932a672921a03210c8aefe23ac0a7d6996ed2d/Merlin/Main/Hosts/IronRuby.Rack/Application.cs#L32
with the prepared environment, which delegates to the Rack application’s
“call” method (registered in the config.ru file). All C# <-> Ruby
interaction happens in the
RubyEnginehttp://github.com/jschementi/ironruby/blob/92932a672921a03210c8aefe23ac0a7d6996ed2d/Merlin/Main/Hosts/IronRuby.Rack/RubyEngine.cs

§ Rack application does its thing (process Rails/Sinatra request, or
deal with things
itselfhttp://github.com/jschementi/ironruby/blob/92932a672921a03210c8aefe23ac0a7d6996ed2d/Merlin/Main/Hosts/IronRuby.Rack/IronRuby.Rack.Example/app.rb)
and returns a response according to the Rack
specificationhttp://rack.rubyforge.org/doc/SPEC.html

§ Takes the Rack response and pass the appropriate data to the IIS
response (response body, status, headers)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs