1.1.3 • Published 8 years ago

aliez-match v1.1.3

Weekly downloads
4
License
Apache-2.0
Repository
-
Last release
8 years ago

aliez-match

aliez路由规则匹配

用法

var aliez = require('aliez'), http = require('http');
var aliez_match = require('aliez-match');

var app = aliez(function(req, res){
	// 纯字符串匹配
	req.match('/', function(req, res){
		res.end('hello world');
	});
	
	// 使用正则表达式
	req.match(/^\/image\/([a-zA-Z0-9]*)/, function(req, res){
		// 匹配结果
		res.end('image:' + req.REQUEST[0]);
	});
	
	// 使用字符串模板
	req.match('/tag/$tag/page/$page', function(req, res){
		// 匹配结果
		res.end('tag:' + req.REQUEST.tag + ' page:' + req.REQUEST.page);
	});
});

app.use(aliez_match);

http.createServer(app).listen(8080);
1.1.3

8 years ago

1.1.2

8 years ago