Commit 4fea37cd authored by Bilbo Brovall's avatar Bilbo Brovall 💬
Browse files

Added some rows to the readme

parent 70616819
Pipeline #14429 passed with stages
in 34 seconds
......@@ -27,6 +27,15 @@ mkdir transport
```
create file transport/mqtt_router.py
```python
"""
The dispatch function passes the following kwargs
endpoint
client
user_data
message
context: is the named parameters in the path
?payload_data: is message parsed as json
"""
from libmqtt.router import hook_route
@hook_route(('import/data',)) # hooks to given topic/topics
......@@ -35,6 +44,14 @@ def import_data(*args, **kwargs): # pylint: disable=unused-argument
csv = kwargs.get('message').payload.decode("utf-8")
ImportCsv(data=csv)
kwargs['client'].publish('hello/world', 'message can be string or json')
# sending {"gender": "man"} to hello/bilbo results in
@hook_route(('hello/(?P<name>+)',)) # hooks to given hello/#
def import_data(*args, **kwargs): # pylint: disable=unused-argument
"""sending {"gender": "man} to hello/bilbo results in"""
context = kwargs.get('context', {}) # is {"name": "bilbo"}
data = kwargs.get('payload_data', {}) # is {"gender": "man"}
```
### Send messages
......@@ -56,4 +73,4 @@ def import_data(*args, **kwargs): # pylint: disable=unused-argument
### Testing
* [flake8](http://flake8.pycqa.org/en/latest/)
* [pylint](https://docs.pylint.org)
* [setuptools-lint](https://pypi.python.org/pypi/setuptools-lint)
\ No newline at end of file
* [setuptools-lint](https://pypi.python.org/pypi/setuptools-lint)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment