PDA

View Full Version : [RedHanded] Day Camp at Mongrel National Park


ruby-lang
March 8th, 2006, 08:25 PM
<p>Zed and I worked over the weekend on smoothing out the divide between Camping (the 4k web framework) and Mongrel (the slim new Ruby web server mentioned last week.) In just a few days, Mongrel has caught the scent and is totally Campnivorous. Development gems await you.</p>


<pre>
gem install mongrel camping --source code.whytheluckystiff.net
</pre>

<p>The Mongrel gem requires a build environment, there are no <span class="caps">OSX</span> or Windows binaries yet. You will find two examples in Mongrel’s <a href="http://rubyforge.org/plugins/scmsvn/viewcvs.php/trunk/examples/camping/?root=mongrel">examples/camping</a> directory. Tepee is a dead-simple versioning wiki which requires the <code>acts_as_versioned</code> gem.</p>


<p>Here’s the relevant handler which is executed with <code>CampingHandler.new(Tepee)</code>, if the app is contained in the module <code>Tepee</code>.</p>


<pre>
class CampingHandler < Mongrel::HttpHandler
def initialize(klass)
@klass = klass
end
def process(request, response)
body = StringIO.new(request.body)
controller = @klass.run(body, request.params)
response.start(controller.status) do |head, out|
controller.headers.each do |k, v|
[*v].each do |vi|
head[k] = vi
end
end
out << controller.body
end
end
end
</pre>

<p>You can then mount these handlers quite readily. Zed’s moving along with handsome stride, so if you’ve got a machine to build this on, do not delay.</p>

<a href="http://redhanded.hobix.com/inspect/dayCampAtMongrelNationalPark.html" target="_blank">http://redhanded.hobix.com/inspect/dayCampAtMongrelNationalPark.html</a>