Skip to content

Commit

Permalink
web/build-details: directly use Version in extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
syphar committed Feb 29, 2024
1 parent ff55165 commit 70b46ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/web/build_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ use crate::{
error::{AxumNope, AxumResult},
extractors::{DbConnection, Path},
file::File,
MetaData, ReqVersion,
MetaData,
},
AsyncStorage, Config,
};
use anyhow::Context as _;
use axum::{extract::Extension, response::IntoResponse};
use chrono::{DateTime, Utc};
use semver::Version;
use serde::Serialize;
use std::sync::Arc;

Expand All @@ -36,13 +37,12 @@ impl_axum_webpage! {
}

pub(crate) async fn build_details_handler(
Path((name, version, id)): Path<(String, ReqVersion, String)>,
Path((name, version, id)): Path<(String, Version, String)>,
mut conn: DbConnection,
Extension(config): Extension<Arc<Config>>,
Extension(storage): Extension<Arc<AsyncStorage>>,
) -> AxumResult<impl IntoResponse> {
let id: i32 = id.parse().map_err(|_| AxumNope::BuildNotFound)?;
let version = version.assume_exact()?;

let row = sqlx::query!(
"SELECT
Expand Down
8 changes: 0 additions & 8 deletions src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ pub(crate) enum ReqVersion {
}

impl ReqVersion {
fn assume_exact(self) -> Result<Version, AxumNope> {
if let ReqVersion::Exact(version) = self {
Ok(version)
} else {
Err(AxumNope::VersionNotFound)
}
}

pub(crate) fn is_latest(&self) -> bool {
matches!(self, ReqVersion::Latest)
}
Expand Down

0 comments on commit 70b46ac

Please sign in to comment.