Handler framework for the Mongrel2 web server.
Updates for more recent (v1.6.0) nim.
Fix nimble file for distribution.
Re-arrange for use with nimble, updates for nim 0.19.


browse log




#What's this?

This module implements a basic framework for interacting with the Mongrel2 webserver. (http://mongrel2.org).


The easiest way to install this module is via the nimble package manager, by simply running 'nimble install mongrel2'.

Alternatively, you can fetch the 'mongrel2.nim' file yourself, and put it in a place of your choosing.


The "bare minimum" required for testing your Mongrel2 configuration is nearly a one-liner.

import mongrel2
newM2Handler( "app-id", "tcp://", "tcp://" ).run

Assuming your Mongrel2 server is configured correctly, you should be able to steer a browser to your handler to see a helpful message.

To do anything more complex, you'll want to look at the module documentation. Here's a "hello world":

let handler = newM2Handler( "app-id", "tcp://", "tcp://" )

proc hello_world( request: M2Request ): M2Response =
    result = request.response
    result[ "Content-Type" ] = "text/plain"
    result.body = "Hello there, world!"
    result.status = HTTP_OK

handler.action = hello_world

This module would be suitable to build a more elaborate framework around, such as Ruby's "Strelka" (https://github.com/ged/strelka). I may eventually look into integration with Jasper, as well.