Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

unfancy routing

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 tests
Octocat-spinner-32 README.md
Octocat-spinner-32 package.json
README.md

イカ

braindead routes.

var routes = require('ika').routes
routes.add('GET', /\/borges\/(\w+)\//, function(book) {
    this.res.writeHead(200, {'Content-Type':'text/plain'})
    if (book === 'babel') {
        this.res.end('a triangular room is inconceivable')
    }
    else {
        this.res.end('no such book')
    }
})

routes.add('POST', '/borges/add/', function() {
   // do work 
})
var server = http.createServer(function(req, res) {
    routes.route(req, res)
})
  • pass a regex literal or a string
  • req and res are properties in the context of the callback
  • captured args in regex are passed as params to callback
  • that's it.

meta

ika was written by nathaniel k smith nathanielksmith@gmail.com and is licensed under the terms of the GPL3.

Something went wrong with that request. Please try again.