Wouter
Wouter is a modular web framework built on top of Rack.
Wouter design goals: explicit, modular, readable.
Quick Example
Wouter allows you to define routes that connect to endpoints.
Here is an example rackup compatible config.ru:
require 'wouter'
class HelloWorld < Wouter::Endpoint
def respond
'Hello, world!'
end
end
class Routes < Wouter
get '/', HelloWorld
end
run Routes.build
Intances of Wouter::Endpoint are Rack applications. Instances of Wouter are Rack applications. Wouter builds routes to dispatch requests to Wouter::Endpoint instances.
An example application can be viewed here.
Instances of Wouter
When you create an instance of the Wouter class, you must call .build to create the Rack application.
Wouter DSL
HTTP routes:
getputpostdelete
Rack middleware:
middleware- add Rack middleware
Instaces of Wouter::Endpoint
Instances of Wouter::Endpoint have access to a few helper methods.
req- an instance ofRack::Requestfor the current HTTP requestres- an instance ofRack::Responsefor the current HTTP responseparams- convience method for access toreq.paramsand any URL route parametersheaders- convience method for getting and setting HTTP headersstatus- get or set HTTP status codenot_found- generates a HTTP 404 Not FoundRack::Response
Extensions
- wouter-views - View template support for Wouter web framework