summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/main.rs b/src/main.rs
index 00fc6ce..70c67cf 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,8 +11,8 @@ use axum::{
11}; 11};
12use dashmap::DashMap; 12use dashmap::DashMap;
13use sqlx::PgPool; 13use sqlx::PgPool;
14use time::UtcOffset;
15use std::{env, sync::Arc}; 14use std::{env, sync::Arc};
15use time::UtcOffset;
16use tokio::sync::broadcast::{channel, Sender}; 16use tokio::sync::broadcast::{channel, Sender};
17use tracing::{info, level_filters::LevelFilter}; 17use tracing::{info, level_filters::LevelFilter};
18use tracing_subscriber::{ 18use tracing_subscriber::{
@@ -29,7 +29,7 @@ use utoipa_swagger_ui::SwaggerUi;
29mod config; 29mod config;
30mod db; 30mod db;
31mod error; 31mod error;
32mod extractors; 32mod auth;
33mod routes; 33mod routes;
34mod services; 34mod services;
35mod wol; 35mod wol;
@@ -37,19 +37,21 @@ mod wol;
37#[derive(OpenApi)] 37#[derive(OpenApi)]
38#[openapi( 38#[openapi(
39 paths( 39 paths(
40 start::start, 40 start::post,
41 start::get,
42 start::start_payload,
41 device::get, 43 device::get,
42 device::get_path, 44 device::get_payload,
43 device::post, 45 device::post,
44 device::put, 46 device::put,
45 ), 47 ),
46 components( 48 components(
47 schemas( 49 schemas(
50 start::PayloadOld,
48 start::Payload, 51 start::Payload,
49 start::Response, 52 start::Response,
50 device::PutDevicePayload, 53 device::DevicePayload,
51 device::GetDevicePayload, 54 device::GetDevicePayload,
52 device::PostDevicePayload,
53 db::DeviceSchema, 55 db::DeviceSchema,
54 ) 56 )
55 ), 57 ),
@@ -116,14 +118,16 @@ async fn main() -> color_eyre::eyre::Result<()> {
116 }; 118 };
117 119
118 let app = Router::new() 120 let app = Router::new()
119 .route("/start", post(start::start)) 121 .route("/start", post(start::start_payload))
122 .route("/start/:id", post(start::post).get(start::get))
120 .route( 123 .route(
121 "/device", 124 "/device",
122 post(device::post).get(device::get).put(device::put), 125 post(device::post).get(device::get_payload).put(device::put),
123 ) 126 )
124 .route("/device/:id", get(device::get_path)) 127 .route("/device/:id", get(device::get))
125 .route("/status", get(status::status)) 128 .route("/status", get(status::status))
126 .route_layer(from_fn_with_state(shared_state.clone(), extractors::auth)) 129 // TODO: Don't load on `None` Auth
130 .route_layer(from_fn_with_state(shared_state.clone(), auth::auth))
127 .merge(SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", ApiDoc::openapi())) 131 .merge(SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", ApiDoc::openapi()))
128 .with_state(Arc::new(shared_state)); 132 .with_state(Arc::new(shared_state));
129 133