Skip to content

Commit

Permalink
chore: enable rest plugin only if in config or if --rest-http-port is…
Browse files Browse the repository at this point in the history
… set (#1593)

* chore: enable rest plugin only if in config or if --rest-http-port is passed

Signed-off-by: Gabriele Baldoni <[email protected]>

* Update README with --rest-http-port option

---------

Signed-off-by: Gabriele Baldoni <[email protected]>
Co-authored-by: Luca Cominardi <[email protected]>
  • Loading branch information
gabrik and Mallets authored Dec 6, 2024
1 parent b7d2051 commit 65a0c04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Zenoh's router is built as `target/release/zenohd`. All the examples are built i
* run the Zenoh router with permission to perform config changes via the admin space, and with a memory storage:

```sh
./target/release/zenohd --adminspace-permissions=rw --cfg='plugins/storage_manager/storages/demo:{key_expr:"demo/example/**",volume:"memory"}'
./target/release/zenohd --rest-http-port=8000 --adminspace-permissions=rw --cfg='plugins/storage_manager/storages/demo:{key_expr:"demo/example/**",volume:"memory"}'
```

* in another shell, get info of the zenoh router via the zenoh admin space (you may use `jq` for pretty json formatting):
Expand Down Expand Up @@ -246,11 +246,11 @@ By default the Zenoh router is delivered or built with 2 plugins. These may be c
> [!WARNING]
> Since `v0.6`, `zenohd` no longer loads every available plugin at startup. Instead, only configured plugins are loaded (after processing `--cfg` and `--plugin` options). Once `zenohd` is running, plugins can be hot-loaded and, if they support it, reconfigured at runtime by editing their configuration through the adminspace.

Note that the REST plugin is added to the configuration by the default value of the `--rest-http-port` CLI argument.

**[REST plugin](https://zenoh.io/docs/manual/plugin-http/)** (exposing a REST API):
This plugin converts GET and PUT REST requests into Zenoh gets and puts respectively.

Note that to activate the REST plugin on `zenohd` the CLI argument should be passed: `--rest-http-port=8000` (or any other port of your choice).

**[Storages plugin](https://zenoh.io/docs/manual/plugin-storage-manager/)** (managing [backends and storages](https://zenoh.io/docs/manual/plugin-storage-manager/#backends-and-volumes))
This plugin allows you to easily define storages. These will store key-value pairs they subscribed to, and send the most recent ones when queried. Check out [DEFAULT_CONFIG.json5](DEFAULT_CONFIG.json5) for info on how to configure them.

Expand Down
5 changes: 2 additions & 3 deletions zenohd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ fn config_from_args(args: &Args) -> Config {
if let Some(id) = &args.id {
config.set_id(id.parse().unwrap()).unwrap();
}
// apply '--rest-http-port' to config only if explicitly set (overwriting config),
// or if no config file is set (to apply its default value)
if args.rest_http_port.is_some() || args.config.is_none() {
// apply '--rest-http-port' to config only if explicitly set (overwriting config)
if args.rest_http_port.is_some() {
let value = args.rest_http_port.as_deref().unwrap_or("8000");
if !value.eq_ignore_ascii_case("none") {
config
Expand Down

0 comments on commit 65a0c04

Please sign in to comment.