node-red-contrib-routing
Version:
A Node-RED node to route incoming messages based on their topics.
37 lines (27 loc) • 910 B
Markdown
A Node-RED node to route incoming messages based on their topics.
It is inspired by [Ruby on Rails' routing](http://api.rubyonrails.org/classes/ActionDispatch/Routing.html) and [Express.js' routing](https://expressjs.com/en/guide/routing.html). It uses [rlite](https://github.com/chrisdavies/rlite) to match a message to a single route.

* `iot/:sensor/humidity`
* `iot/:sensor/temperature`
* `traffic`
```json
{
"topic": "iot/AJ08/humidity",
"payload": "18"
}
```
Will match the route `iot/:sensor/humidity` and the forwarded message will be :
```json
{
"topic": "iot/AJ08/humidity",
"payload": "18",
"params": {
"sensor": "AJ08"
}
}
```