Wednesday 10 February 2016

General routing module.

I was wondering if anyone is away of a generic routing module in node.js. The only routing modules I can find, are specifically used for webservers. (Express)I want to use the router for an other purpose (MQTT topic handling). And so I'm looking for a module that takes an string, parses it and handles it, while using variables used in the string.For example:router.register("/foo/(device)/(sensor)", function(device, sensor) { ... }); router.register("/bar/subcription/(id)", function(id) { ... }); in this case, a the string "/foo/alarm/door" should be handled by route 1, while "/bar/subscription/abc" is handled by route 2. In both cases, parts of the string are parsed and used as variables for the closure.If no such module exists, I'll try to built it myself. But I don't want to reinvent the wheel. :)Thanks in advance!EDIT: Typo

Submitted February 10, 2016 at 03:53PM by MrMaverick82

No comments:

Post a Comment