2.0.0 • Published 6 years ago

regex-router v2.0.0

Weekly downloads
34
License
MIT
Repository
github
Last release
6 years ago

Regex-router

npm version

Regex-router is a simple Node.js library to simplify web application routing without using a framework.

Example

var fs = require('fs');
var http = require('http');
var Router = require('regex-router');

var R = new Router(function(req, res, m) {
  res.end('404. URL not found: ' + req.url);
});

R.get(/^\/page\/(\w+)/, function(req, res, m) {
  console.log('Serving URL: %s', req.url);
  var page_name = m[1];
  var page_path = __dirname + '/static_pages/' + page_name + '.html';
  fs.readFile(page_path, 'utf8', function(err, html) {
    res.write(html);
    res.end();
  });
});

http.createServer(function(req, res) {
  R.route(req, res);
}).listen(80);

License

Copyright 2012-2015 Christopher Brown. MIT Licensed.

2.0.0

6 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.2.0

11 years ago

0.1.9

11 years ago

0.1.7

11 years ago

0.1.6

11 years ago

0.1.5

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

12 years ago

0.1.1

12 years ago