Move typed paths to separate module
This commit is contained in:
parent
3d5a277234
commit
058ed2e85c
6 changed files with 85 additions and 27 deletions
|
|
@ -1,8 +1,9 @@
|
|||
mod admin;
|
||||
pub mod api;
|
||||
mod api;
|
||||
mod commit;
|
||||
mod index;
|
||||
mod link;
|
||||
pub mod paths;
|
||||
mod queue;
|
||||
mod r#static;
|
||||
mod worker;
|
||||
|
|
|
|||
|
|
@ -3,16 +3,11 @@ use axum::{
|
|||
response::{IntoResponse, Redirect},
|
||||
Form,
|
||||
};
|
||||
use axum_extra::routing::TypedPath;
|
||||
use serde::Deserialize;
|
||||
use sqlx::SqlitePool;
|
||||
use time::OffsetDateTime;
|
||||
|
||||
use crate::{config::Config, somehow};
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/admin/queue/add")]
|
||||
pub struct PathAdminQueueAdd {}
|
||||
use crate::{config::Config, server::web::paths::PathAdminQueueAdd, somehow};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct FormAdminQueueAdd {
|
||||
|
|
|
|||
|
|
@ -12,9 +12,7 @@ use axum::{
|
|||
response::{IntoResponse, Response},
|
||||
Json, TypedHeader,
|
||||
};
|
||||
use axum_extra::routing::TypedPath;
|
||||
use gix::{ObjectId, ThreadSafeRepository};
|
||||
use serde::Deserialize;
|
||||
use sqlx::{Acquire, SqlitePool};
|
||||
use time::OffsetDateTime;
|
||||
use tracing::debug;
|
||||
|
|
@ -22,6 +20,10 @@ use tracing::debug;
|
|||
use crate::{
|
||||
config::Config,
|
||||
server::{
|
||||
web::paths::{
|
||||
PathApiWorkerBenchRepoByHashTreeTarGz, PathApiWorkerRepoByHashTreeTarGz,
|
||||
PathApiWorkerStatus,
|
||||
},
|
||||
workers::{WorkerInfo, Workers},
|
||||
BenchRepo, Repo,
|
||||
},
|
||||
|
|
@ -116,10 +118,6 @@ async fn save_work(finished: FinishedRun, db: &SqlitePool) -> somehow::Result<()
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/api/worker/status")]
|
||||
pub struct PathApiWorkerStatus {}
|
||||
|
||||
pub async fn post_api_worker_status(
|
||||
_path: PathApiWorkerStatus,
|
||||
State(config): State<&'static Config>,
|
||||
|
|
@ -199,12 +197,6 @@ fn stream_response(repo: Arc<ThreadSafeRepository>, id: ObjectId) -> impl IntoRe
|
|||
)
|
||||
}
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/api/worker/repo/:hash/tree.tar.gz")]
|
||||
pub struct PathApiWorkerRepoByHashTreeTarGz {
|
||||
pub hash: String,
|
||||
}
|
||||
|
||||
pub async fn get_api_worker_repo_by_hash_tree_tar_gz(
|
||||
path: PathApiWorkerRepoByHashTreeTarGz,
|
||||
State(config): State<&'static Config>,
|
||||
|
|
@ -224,12 +216,6 @@ pub async fn get_api_worker_repo_by_hash_tree_tar_gz(
|
|||
Ok(stream_response(repo.0, id).into_response())
|
||||
}
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/api/worker/bench_repo/:hash/tree.tar.gz")]
|
||||
pub struct PathApiWorkerBenchRepoByHashTreeTarGz {
|
||||
pub hash: String,
|
||||
}
|
||||
|
||||
pub async fn get_api_worker_bench_repo_by_hash_tree_tar_gz(
|
||||
path: PathApiWorkerBenchRepoByHashTreeTarGz,
|
||||
State(config): State<&'static Config>,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use sqlx::SqlitePool;
|
|||
|
||||
use crate::{config::Config, server::util, somehow};
|
||||
|
||||
use super::{admin::queue::PathAdminQueueAdd, link::CommitLink, Base, Tab};
|
||||
use super::{link::CommitLink, paths::PathAdminQueueAdd, Base, Tab};
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path = "commit.html")]
|
||||
|
|
|
|||
76
src/server/web/paths.rs
Normal file
76
src/server/web/paths.rs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
use axum_extra::routing::TypedPath;
|
||||
use serde::Deserialize;
|
||||
|
||||
////////////////
|
||||
// Html pages //
|
||||
////////////////
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/")]
|
||||
pub struct PathIndex {}
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/queue")]
|
||||
pub struct PathQueue {}
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/queue/inner")]
|
||||
pub struct PathQueueInner {}
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/commit/:hash")]
|
||||
pub struct PathCommitByHash {
|
||||
pub hash: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/run/:id")]
|
||||
pub struct PathRunById {
|
||||
pub id: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/worker/:name")]
|
||||
pub struct PathWorkerByName {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
///////////////////
|
||||
// Admin actions //
|
||||
///////////////////
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/admin/queue/add")]
|
||||
pub struct PathAdminQueueAdd {}
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/admin/queue/delete")]
|
||||
pub struct PathAdminQueueDelete {}
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/admin/queue/increase")]
|
||||
pub struct PathAdminQueueIncrease {}
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/admin/queue/decrease")]
|
||||
pub struct PathAdminQueueDecrease {}
|
||||
|
||||
/////////
|
||||
// Api //
|
||||
/////////
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/api/worker/status")]
|
||||
pub struct PathApiWorkerStatus {}
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/api/worker/repo/:hash/tree.tar.gz")]
|
||||
pub struct PathApiWorkerRepoByHashTreeTarGz {
|
||||
pub hash: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/api/worker/bench_repo/:hash/tree.tar.gz")]
|
||||
pub struct PathApiWorkerBenchRepoByHashTreeTarGz {
|
||||
pub hash: String,
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ use tracing::{debug, warn};
|
|||
|
||||
use crate::{
|
||||
config::{Config, WorkerServerConfig},
|
||||
server::web::api::worker::{
|
||||
server::web::paths::{
|
||||
PathApiWorkerBenchRepoByHashTreeTarGz, PathApiWorkerRepoByHashTreeTarGz,
|
||||
PathApiWorkerStatus,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue