Skip to content

Commit 70b46ac

Browse files
committed
web/build-details: directly use Version in extractor
1 parent ff55165 commit 70b46ac

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/web/build_details.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ use crate::{
44
error::{AxumNope, AxumResult},
55
extractors::{DbConnection, Path},
66
file::File,
7-
MetaData, ReqVersion,
7+
MetaData,
88
},
99
AsyncStorage, Config,
1010
};
1111
use anyhow::Context as _;
1212
use axum::{extract::Extension, response::IntoResponse};
1313
use chrono::{DateTime, Utc};
14+
use semver::Version;
1415
use serde::Serialize;
1516
use std::sync::Arc;
1617

@@ -36,13 +37,12 @@ impl_axum_webpage! {
3637
}
3738

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

4747
let row = sqlx::query!(
4848
"SELECT

src/web/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,6 @@ pub(crate) enum ReqVersion {
8080
}
8181

8282
impl ReqVersion {
83-
fn assume_exact(self) -> Result<Version, AxumNope> {
84-
if let ReqVersion::Exact(version) = self {
85-
Ok(version)
86-
} else {
87-
Err(AxumNope::VersionNotFound)
88-
}
89-
}
90-
9183
pub(crate) fn is_latest(&self) -> bool {
9284
matches!(self, ReqVersion::Latest)
9385
}

0 commit comments

Comments
 (0)