m_mqtt_ticket (zotonic_mod_base v1.0.0-rc.17)
A ticketing system for out of band MQTT posts via HTTP.
The controller controller_mqtt_transport can accept HTTP posts. These posts MUST include a ticket and a topic for the payload to be sent.
The ticket is obtained via model/mqtt_ticket/post/new. This can only be accessed via MQTT, as the routines will check
for a valid client_id.
If a ticket is created then the current request context is saved for max 30 seconds. If a request comes in then the ticket is used to fetch the stored context and the following information is copied over from the stored context to the HTTP request context:
- MQTT client-id
- MQTT client-topic
- MQTT routing-id
- ACL user id
- ACL auth_options
- ACL read-only flag
- Timezone
- Language
A ticket can only be used once.
Available Model API Paths
| Method | Path pattern | Description |
|---|---|---|
post | /new | Create a one-time MQTT transport ticket for the current MQTT client context and return the generated ticket id (binary). No further lookups. |
delete | /+ticket | Invalidate/delete ticket +ticket and its stored context so it can no longer be exchanged. No further lookups. |
/+name marks a variable path segment. A trailing /... means extra path segments are accepted for further lookups.
Summary
Functions
-spec m_delete([binary()], zotonic_model:opt_msg(), z:context()) -> {ok, term()} | ok | {error, term()}.
-spec m_get(list(), zotonic_model:opt_msg(), z:context()) -> zotonic_model:return().
-spec m_post([binary()], zotonic_model:opt_msg(), z:context()) -> {ok, term()} | ok | {error, term()}.