Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Guide

coffeemate edited this page · 5 revisions
Clone this wiki locally

About Install Quickstart Documentation Guide Source

Guide

  • 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.
require('http').createServer(
      require('meryl')

        .plug(require('connect').static('/srv/static_content'))

        .plug(
          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'); })

        .cgi()
      ).listen(3000);
Something went wrong with that request. Please try again.