use crate::command::service::CommandManagementService; use crate::http::error::HttpServerResultError; use actix_web::{get, post, web, Responder}; use std::sync::Arc; #[post("/cmd/{name:[\\w\\d/_-]+}")] pub(super) async fn send_command( command_service: web::Data>, name: web::Path, parameters: web::Json>, ) -> Result { let result = command_service .send_command(name.to_string(), parameters.into_inner()) .await?; Ok(web::Json(result)) } #[get("/cmd")] pub(super) async fn get_all( command_service: web::Data>, ) -> Result { Ok(web::Json(command_service.get_commands()?)) } #[get("/cmd/{name:[\\w\\d/_-]+}")] pub(super) async fn get_one( command_service: web::Data>, name: web::Path, ) -> Result { Ok(web::Json( command_service.get_command_definition(&name.to_string()), )) }