Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: enable rest plugin only if in config or if --rest-http-port is set #1593

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading