Process the CommandRequest from the OpenAPI Spec in the execute handler
This is where the rubber starts to meet the road
This commit is contained in:
parent
cc8cc30b17
commit
6d963464cf
|
@ -18,12 +18,29 @@ mod routes {
|
|||
|
||||
pub mod api {
|
||||
use crate::caps::*;
|
||||
use janky::CommandRequest;
|
||||
use log::*;
|
||||
use tide::{Body, Request};
|
||||
|
||||
pub fn register(app: &mut tide::Server<()>) {
|
||||
app.at("/api/v1/capabilities").get(get_caps);
|
||||
app.at("/api/v1/execute").put(execute);
|
||||
}
|
||||
|
||||
/*
|
||||
* PUT /execute
|
||||
*
|
||||
* This will take in the commands to actually execute
|
||||
*/
|
||||
pub async fn execute(mut req: Request<()>) -> Result<Body, tide::Error> {
|
||||
let commands: CommandRequest = req.body_json().await?;
|
||||
debug!("Commands to exec: {:?}", commands);
|
||||
Ok("{}".into())
|
||||
}
|
||||
|
||||
/*
|
||||
* GET /capabilities
|
||||
*/
|
||||
pub async fn get_caps(_req: Request<()>) -> Result<Body, tide::Error> {
|
||||
let response = json!({
|
||||
"caps" : [
|
||||
|
|
|
@ -20,17 +20,17 @@ struct CapsResponse {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
struct Command {
|
||||
pub struct Command {
|
||||
script: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
struct CommandRequest {
|
||||
pub struct CommandRequest {
|
||||
commands: Vec<Command>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
|
||||
struct CommandResponse {
|
||||
pub struct CommandResponse {
|
||||
uuid: Uuid,
|
||||
stream_url: Option<Url>,
|
||||
task_url: Url,
|
||||
|
|
Loading…
Reference in New Issue