public
Fork of ironruby/ironruby
Description: Microsoft's Ruby language compiler that is built on top of the Dynamic Language Runtime.
Homepage: http://ironruby.net
Clone URL: git://github.com/jschementi/ironruby.git
ironruby / Merlin / Main / Hosts / IronRuby.Rack
Merlin/Main/Hosts/IronRuby.Rack/README.markdown

ironruby-rack

Run Rack-based web applications on IIS with IronRuby

Deploying on IIS

Setup

  1. Install Rack

    igem install rack

  2. Install IIS (this set of features might be overkill)

    • Control Panel -> Programs -> Turn Windows Features on or off
    • Internet Information Services
      • World Wide Web Services, enable:
        • Application Development Features
        • Common HTTP Features -> Default Document, Directory Browsing, HTTP Redirection and Static Content
        • Performance features -> Static Content Compression
        • Security -> Request Filtering and Windows Authentication
      • Web Management Tools, enable:
        • IIS 6 Management Compatibility -> IIS Metabase and IIS6 configuration compatibility
        • IIS Management Console
        • IIS Management Script and Tools
        • IIS Management Service
  3. Give permissions to IIS

    • IIS needs to have permission to open files in this project, as well as in the Ruby standard library. Grant IIS_IUSER permission to this directory, as well as the Ruby standard library (usually C:\ruby\lib\ruby)
  4. Open IronRack.sln in Visual Studio

    • Click "OK" to prompts about creating virtual directories, otherwise not all the project files will load.
    • Right-click on IronRuby.Rack.App and select "Set as StartUp Project".

Building

Simply build the solution in Visual Studio. It will build IronRuby, as well as IronRuby.Rack.dll.

Running

Click "Debug" -> "Start without Debugging" to run the Rack Application, which will just navigate to http://localhost/IronRuby.Rack.Example

How it works

  • Uses ASP.NET's HttpHandlers to
    • Registering IronRuby.Rack in the Rack-based application's Web.config
    • Load a Rack-based application on startup (HttpHandlerFactory and Application constructor).
      • Initializes Rack and runs the application's config.ru, which tells Rack what application (any Ruby object that responds to 'call')
    • Intercept web requests (HttpHandler.ProcessRequest)
      • Creates a Request and a Response, and passes it off to IIS.Handle which:
        • Set up the environment according to the Rack specification
        • Calls Application.Call 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 RubyEngine.
        • Rack application does its thing (process Rails/Sinatra request, or deal with things itself) and returns a response according to the Rack specification.
        • Takes the Rack response and pass the appropriate data to the IIS response (response body, status, headers)