Add version method to HTTP RPC endpoint

This commit is contained in:
Tobie Morgan Hitchcock 2022-10-12 19:58:43 +01:00
parent 2b92d24476
commit 9546b07d71

View file

@ -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