diff options
author | FxQnLr <[email protected]> | 2024-04-09 22:07:10 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2024-04-09 22:07:10 +0200 |
commit | 907e5cb5bc48899b444f7fedd85af7b5974d9a2e (patch) | |
tree | 7206da6c47e6c9e2da0982344c8f76f1385e0ae2 /src/main.rs | |
parent | 8dca7e83519b6c3531653cdedf60b2a14e1035b7 (diff) | |
parent | d91edaf85a1a179a915ac99e7c17b5647d8d9f7d (diff) | |
download | webol-907e5cb5bc48899b444f7fedd85af7b5974d9a2e.tar webol-907e5cb5bc48899b444f7fedd85af7b5974d9a2e.tar.gz webol-907e5cb5bc48899b444f7fedd85af7b5974d9a2e.zip |
Merge pull request #28 from FxQnLr/0.3.4
0.3.4
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 24 |
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 | }; |
12 | use dashmap::DashMap; | 12 | use dashmap::DashMap; |
13 | use sqlx::PgPool; | 13 | use sqlx::PgPool; |
14 | use time::UtcOffset; | ||
15 | use std::{env, sync::Arc}; | 14 | use std::{env, sync::Arc}; |
15 | use time::UtcOffset; | ||
16 | use tokio::sync::broadcast::{channel, Sender}; | 16 | use tokio::sync::broadcast::{channel, Sender}; |
17 | use tracing::{info, level_filters::LevelFilter}; | 17 | use tracing::{info, level_filters::LevelFilter}; |
18 | use tracing_subscriber::{ | 18 | use tracing_subscriber::{ |
@@ -29,7 +29,7 @@ use utoipa_swagger_ui::SwaggerUi; | |||
29 | mod config; | 29 | mod config; |
30 | mod db; | 30 | mod db; |
31 | mod error; | 31 | mod error; |
32 | mod extractors; | 32 | mod auth; |
33 | mod routes; | 33 | mod routes; |
34 | mod services; | 34 | mod services; |
35 | mod wol; | 35 | mod 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 | ||