Skip to content

Commit e972692

Browse files
committed
check passes
1 parent fd922b4 commit e972692

File tree

10 files changed

+47
-42
lines changed

10 files changed

+47
-42
lines changed

Cargo.lock

Lines changed: 12 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ serde_json = "1.0"
7878
serde_with = "3.4.0"
7979

8080
# axum dependencies
81-
axum = { version = "0.7.3", features = ["macros"] }
82-
axum-extra = { version = "0.9.1", features = ["typed-header"] }
81+
async-trait = "0.1.83"
82+
axum = { version = "0.8.1", features = ["macros"] }
83+
axum-extra = { version = "0.10.0", features = ["typed-header"] }
8384
tower = "0.5.1"
8485
tower-http = { version = "0.6.0", features = ["fs", "trace", "timeout", "catch-panic"] }
8586
mime = "0.3.16"

src/bin/cratesfyi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::str::FromStr;
66
use std::sync::Arc;
77

88
use anyhow::{anyhow, Context as _, Error, Result};
9-
use axum::async_trait;
9+
use async_trait::async_trait;
1010
use clap::{Parser, Subcommand, ValueEnum};
1111
use docs_rs::cdn::CdnBackend;
1212
use docs_rs::db::{self, add_path_into_database, CrateId, Overrides, Pool};

src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::{
66
AsyncBuildQueue, AsyncStorage, BuildQueue, Config, Index, InstanceMetrics, RegistryApi,
77
ServiceMetrics, Storage,
88
};
9-
use axum::async_trait;
9+
use async_trait::async_trait;
1010
use std::sync::Arc;
1111
use tokio::runtime::Runtime;
1212

src/repositories/github.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::error::Result;
22
use crate::Config;
3-
use axum::async_trait;
3+
use async_trait::async_trait;
44
use chrono::{DateTime, Utc};
55
use reqwest::{
66
header::{HeaderMap, HeaderValue, ACCEPT, AUTHORIZATION, USER_AGENT},

src/repositories/gitlab.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::error::Result;
2-
use axum::async_trait;
2+
use async_trait::async_trait;
33
use chrono::{DateTime, Utc};
44
use reqwest::{
55
header::{HeaderMap, HeaderValue, ACCEPT, AUTHORIZATION, USER_AGENT},

src/repositories/updater.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::error::Result;
22
use crate::repositories::{GitHub, GitLab, RateLimitReached};
33
use crate::utils::MetadataPackage;
44
use crate::{db::Pool, Config};
5-
use axum::async_trait;
5+
use async_trait::async_trait;
66
use chrono::{DateTime, Utc};
77
use futures_util::stream::TryStreamExt;
88
use once_cell::sync::Lazy;

src/web/extractors.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use crate::db::{AsyncPoolClient, Pool};
22
use anyhow::Context as _;
33
use axum::{
4-
async_trait,
5-
extract::{Extension, FromRequestParts},
4+
extract::{Extension, FromRequestParts, OptionalFromRequestParts},
65
http::request::Parts,
76
RequestPartsExt,
87
};
@@ -20,7 +19,6 @@ use super::error::AxumNope;
2019
#[derive(Debug)]
2120
pub(crate) struct DbConnection(AsyncPoolClient);
2221

23-
#[async_trait]
2422
impl<S> FromRequestParts<S> for DbConnection
2523
where
2624
S: Send + Sync,
@@ -55,11 +53,33 @@ impl DerefMut for DbConnection {
5553
/// as error response instead of a plain text "bad request"
5654
#[allow(clippy::disallowed_types)]
5755
mod path_impl {
56+
use serde::de::DeserializeOwned;
57+
5858
use super::*;
5959

6060
#[derive(FromRequestParts)]
6161
#[from_request(via(axum::extract::Path), rejection(AxumNope))]
6262
pub(crate) struct Path<T>(pub T);
63+
64+
impl<T, S> OptionalFromRequestParts<S> for Path<T>
65+
where
66+
T: DeserializeOwned + Send + 'static,
67+
S: Send + Sync,
68+
{
69+
type Rejection = AxumNope;
70+
71+
async fn from_request_parts(
72+
parts: &mut Parts,
73+
_state: &S,
74+
) -> Result<Option<Self>, Self::Rejection> {
75+
<axum::extract::Path<T> as OptionalFromRequestParts<S>>::from_request_parts(
76+
parts, _state,
77+
)
78+
.await
79+
.map(|path| path.map(|obj| Path(obj.0)))
80+
.map_err(|err| AxumNope::BadRequest(err.into()))
81+
}
82+
}
6383
}
6484

6585
pub(crate) use path_impl::Path;

src/web/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,9 @@ async fn apply_middleware(
413413
Ok(router.layer(
414414
ServiceBuilder::new()
415415
.layer(TraceLayer::new_for_http())
416-
.layer(sentry_tower::NewSentryLayer::new_from_top())
416+
// FIXME: send / sync error?
417+
// .layer(sentry_tower::NewSentryLayer::new_from_top())
418+
// .layer(sentry_tower::SentryLayer::new_from_top())
417419
.layer(sentry_tower::SentryHttpLayer::with_transaction())
418420
.layer(middleware::from_fn(
419421
set_sentry_transaction_name_from_axum_route,

src/web/sitemap.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ about_page!(AboutPageMetadata, "core/about/metadata.html");
154154
about_page!(AboutPageRedirection, "core/about/redirections.html");
155155
about_page!(AboutPageDownload, "core/about/download.html");
156156

157+
#[axum::debug_handler]
157158
pub(crate) async fn about_handler(subpage: Option<Path<String>>) -> AxumResult<impl IntoResponse> {
158159
let subpage = match subpage {
159160
Some(subpage) => subpage.0,

0 commit comments

Comments
 (0)