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

improve the way to access to the option and configuration value inside the plugin #56

Open
vincenzopalazzo opened this issue Oct 27, 2022 · 0 comments
Assignees
Labels
plugin API related to cln plugin API 🪀 enhancement New feature or request

Comments

@vincenzopalazzo
Copy link
Collaborator

Take the value from the configuration plugin usually inside the init method is painful

+        .on_init(&|plugin| -> Value {
+            plugin.log(LogLevel::Debug, "Custom init method called");
+            // FIXME: improve the get option plugin API
+            let conf = if let Some(conf_plugin) = &plugin.conf {
+                conf_plugin
+            } else {
+                panic!("this should never happen")
+            };
+            let server_port = conf.options[0].to_owned();
+            let server_port: i32 = from_value(server_port).unwrap();
+            if server_port >= 0 {
+                plugin.log(LogLevel::Info, "running rest server on port {port}");
+                let path = conf.configuration.lightning_dir.as_str();
+                run_rocket(path);
+            }
+            json_utils::init_payload()
+        })
@vincenzopalazzo vincenzopalazzo added 🪀 enhancement New feature or request plugin API related to cln plugin API labels Oct 27, 2022
@vincenzopalazzo vincenzopalazzo self-assigned this Oct 27, 2022
@vincenzopalazzo vincenzopalazzo moved this to In Progress in brink grant 2022-2023 Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin API related to cln plugin API 🪀 enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant