coffeemate edited this page Mar 11, 2011 · 5 revisions
Clone this wiki locally

About Install Quickstart Documentation Guide Source


  • You can chain plugin and handler declerations as well.
  • You may choose using verbose function names instead single letter ones.
  • If you want to register a plugin for processing all requests you can simply pass only your callback to the meryl.p function.
  • You can mark path expression variables as optional using a trailing question mark.
  • Meryl is Connect framework compatible. You can plug any Connect middleware module to Meryl.
  • Below the example demonstrates all the tips above.


          function(req, resp, next) { log(req.params.pathname); next(); })

        .plug('POST *',
          function(req, resp, next) { throw 'restricted'; })

        .handle('GET /',
          function(req, resp) { resp.end('homepage'); })

        .handle('GET /greet/({who}.html)?',
          function(req, resp) { resp.end('Hello, ' + req.params.who || 'World'); })