Skip to content
Snippets Groups Projects

Resolve "New Handler: REST client"

Merged René Schöne requested to merge 61-new-handler-rest-client into dev
2 files
+ 71
9
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 5
1
@@ -14,6 +14,7 @@ Uses Java methods to supply values (receive) and for callbacks (send).
- First leading slash not included in topic.
- Currently, the default mappings are applied, which requires a consumer to expect `byte[]` (instead of a more intuitive token or node value). This might change in future versions.
## MQTT
Use an MQTT broker to receive and send messages.
@@ -31,6 +32,7 @@ Use an MQTT broker to receive and send messages.
- Mqtt is selected by default, so this dependency therefore is required "by default".
- Might work with other versions of `org.fusesource.mqtt-client.mqtt.client` as well.
## REST Server
Create a new REST server with its own target routes.
@@ -38,13 +40,14 @@ Create a new REST server with its own target routes.
- Protocol identifier: `rest`
- URI scheme: `rest://localhost[:port]/<path>`
- Default port: 4567
- Type for mapping definitions: `String` --> TODO --> `byte[]`
- Type for mapping definitions: `byte[]`
- Required runtime dependencies:
- `group: 'com.sparkjava', name: 'spark-core', version: '2.9.3'`
- Receive behaviour: Upon connection, create a new PUT connection and pass the value of every call to this PUT route to the receiving port.
- Send behaviour: Upon connection, create a new GET connection and serve the latest value at this GET route.
- Additional remarks:
- Host is always `localhost`.
- Targets to be invoked need to replace `rest` with `http`
- Might work with newer versions of `com.sparkjava.spark-core` as well.
- For debugging, it is beneficial to include an implementation for [SLF4J][slf4j].
@@ -62,5 +65,6 @@ Invoke REST routes to fetch and send values.
- Send behaviour: When the value to be sent changes, a PUT request sends this data.
- Additional remarks:
- Invoked target replaces `restClient` with `http`
- **Important constraint**: Receiving ports are only supported for tokens, since they interrupt the getter method!
[slf4j]: https://www.slf4j.org/manual.html
Loading