Skip to content

Instantly share code, notes, and snippets.

@CrabDude
Created January 27, 2012 23:44
Show Gist options
  • Save CrabDude/1691626 to your computer and use it in GitHub Desktop.
Save CrabDude/1691626 to your computer and use it in GitHub Desktop.
Director::on not working as expected

This does not fire on http://127.0.0.1:8080/hello:

var http = require('http'),
    director = require('director');

var router = new director.http.Router({
  '/hello': {
    on: function() {
    	this.res.end('Hellow World')
    	console.log('Hellow World');
    }
  }
});

http.createServer(router.dispatch.bind(router)).listen(8080);

But this does:

var http = require('http'),
    director = require('director');

var router = new director.http.Router({
  '/hello': {
    get: function() {
    	this.res.end('Hellow World')
    	console.log('Hellow World');
    }
  }
});

http.createServer(router.dispatch.bind(router)).listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment