summaryrefslogtreecommitdiff
path: root/src/routes
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/start.rs32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/routes/start.rs b/src/routes/start.rs
index c61d5a3..e74a943 100644
--- a/src/routes/start.rs
+++ b/src/routes/start.rs
@@ -18,7 +18,7 @@ use uuid::Uuid;
18 responses( 18 responses(
19 (status = 200, description = "List matching todos by query", body = [Response]) 19 (status = 200, description = "List matching todos by query", body = [Response])
20 ), 20 ),
21 security(("api_key" = [])) 21 security((), ("api_key" = []))
22)] 22)]
23#[deprecated] 23#[deprecated]
24pub async fn start_payload( 24pub async fn start_payload(
@@ -70,13 +70,39 @@ pub async fn start_payload(
70 params( 70 params(
71 ("id" = String, Path, description = "Device id") 71 ("id" = String, Path, description = "Device id")
72 ), 72 ),
73 security(("api_key" = [])) 73 security((), ("api_key" = []))
74)] 74)]
75pub async fn start( 75pub async fn post(
76 State(state): State<Arc<crate::AppState>>, 76 State(state): State<Arc<crate::AppState>>,
77 Path(id): Path<String>, 77 Path(id): Path<String>,
78 payload: Option<Json<Payload>>, 78 payload: Option<Json<Payload>>,
79) -> Result<Json<Value>, Error> { 79) -> Result<Json<Value>, Error> {
80 send_wol(state, &id, payload).await
81}
82
83#[utoipa::path(
84 get,
85 path = "/start/{id}",
86 responses(
87 (status = 200, description = "Start the device with the given id", body = [Response])
88 ),
89 params(
90 ("id" = String, Path, description = "Device id")
91 ),
92 security((), ("api_key" = []))
93)]
94pub async fn get(
95 State(state): State<Arc<crate::AppState>>,
96 Path(id): Path<String>,
97) -> Result<Json<Value>, Error> {
98 send_wol(state, &id, None).await
99}
100
101async fn send_wol(
102 state: Arc<crate::AppState>,
103 id: &str,
104 payload: Option<Json<Payload>>,
105) -> Result<Json<Value>, Error> {
80 info!("Start request for {id}"); 106 info!("Start request for {id}");
81 let device = sqlx::query_as!( 107 let device = sqlx::query_as!(
82 Device, 108 Device,