webmachine.rb travis

Webmachine.rb is a port of Webmachine, which is written in Erlang. The goal of both projects is to expose interesting parts of the HTTP protocol to your application in a declarative way. This means that you are less concerned with handling requests directly and more with describing the behavior of the resources that make up your application. Webmachine is not a web framework per se, but more of a toolkit for building HTTP-friendly applications. For example, it does not provide a templating engine or a persistence layer; those choices are up to you.

NOTE: Webmachine is NOT compatible with Rack. This is intentional! Rack obscures HTTP in a way that makes it hard for Webmachine to do its job properly, and encourages people to add middleware that might break Webmachine's behavior. Rack is also built on the tradition of CGI, which is nice for backwards compatibility but also an antiquated paradigm and should be scuttled (IMHO).

Getting Started

Webmachine.rb is not fully-functional yet, but constructing an application for it will follow this general outline:

require 'webmachine'
# Require any of the files that contain your resources here
require 'my_resource' 

# Point all URIs at the MyResource class
Webmachine::Dispatcher.add_route(['*'], MyResource)

# Start the server, binds to the default interface/port

Your resource will look something like this:

class MyResource < Webmachine::Resource
  def to_html
    "<html><body>Hello, world!</body></html>"

Run the first file and your application is up. That's all there is to it! If you want to customize your resource more, look at the available callbacks in lib/webmachine/resource/callbacks.rb.