#[cfg(feature = "rest-api-actix")]
mod actix;
#[cfg(feature = "rest-api-actix")]
mod error;
mod resources;
use crate::admin::service::AdminService;
use crate::circuit::store;
use crate::rest_api::{Resource, RestResourceProvider};
impl RestResourceProvider for AdminService {
fn resources(&self) -> Vec<Resource> {
#[allow(unused_mut)]
let mut resources = Vec::new();
#[cfg(feature = "rest-api-actix")]
{
resources.append(&mut vec![
actix::ws_register_type::make_application_handler_registration_route(
self.commands(),
),
actix::submit::make_submit_route(self.commands()),
actix::proposals_circuit_id::make_fetch_proposal_resource(self.proposals()),
actix::proposals::make_list_proposals_resource(self.proposals()),
]);
}
resources
}
}
#[derive(Clone)]
pub struct CircuitResourceProvider<T: store::CircuitStore> {
node_id: String,
store: T,
}
impl<T: store::CircuitStore + 'static> CircuitResourceProvider<T> {
pub fn new(node_id: String, store: T) -> Self {
Self { node_id, store }
}
}
impl<T: store::CircuitStore + 'static> RestResourceProvider for CircuitResourceProvider<T> {
fn resources(&self) -> Vec<Resource> {
#[allow(unused_mut)]
let mut resources = Vec::new();
#[cfg(feature = "rest-api-actix")]
{
resources.append(&mut vec![
actix::circuits_circuit_id::make_fetch_circuit_resource(self.store.clone()),
actix::circuits::make_list_circuits_resource(self.store.clone()),
]);
}
resources
}
}