ika

1.0.5 • Public • Published

イカ

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.

Readme

Keywords

none

Package Sidebar

Install

npm i ika

Weekly Downloads

5

Version

1.0.5

License

none

Last publish

Collaborators

  • nathanielksmith