From 9546b07d71728a70991b9d9784095b6cc6938ddb Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Wed, 12 Oct 2022 19:58:43 +0100 Subject: [PATCH] Add version method to HTTP RPC endpoint --- src/net/rpc.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/net/rpc.rs b/src/net/rpc.rs index 35c48e11..4454866a 100644 --- a/src/net/rpc.rs +++ b/src/net/rpc.rs @@ -1,5 +1,7 @@ use crate::cli::CF; use crate::cnf::MAX_CONCURRENT_CALLS; +use crate::cnf::PKG_NAME; +use crate::cnf::PKG_VERS; use crate::dbs::DB; use crate::err::Error; use crate::net::session; @@ -209,6 +211,10 @@ impl Rpc { v if v.is_strand() => rpc.read().await.delete(v).await, _ => return Response::failure(id, Failure::INVALID_PARAMS).send(chn).await, }, + "version" => match params.len() { + 0 => Ok(format!("{}-{}", PKG_NAME, *PKG_VERS).into()), + _ => return Response::failure(id, Failure::INVALID_PARAMS).send(chn).await, + }, _ => return Response::failure(id, Failure::METHOD_NOT_FOUND).send(chn).await, }; // Return the final response