diff options
author | Vika <vika@fireburn.ru> | 2025-01-01 23:17:56 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2025-01-01 23:17:56 +0300 |
commit | d10710326da703f69eaa06723dc66e330fd32745 (patch) | |
tree | e4a32c2a7f2e4a61d1f3f6237977de64e47470ae /src/micropub | |
parent | 675141379067858376698d5f75ab163977d33e3a (diff) | |
download | kittybox-d10710326da703f69eaa06723dc66e330fd32745.tar.zst |
axum: 0.7.9 → 0.8.1
Some breaking changes. For better or for worse. The optional extractor breaking change is a double-edged sword, since not all extractors can be used with `Option<T>` now, and you have to use `Result<T, T::Rejection>` even when you want to ignore an error coming from an extractor, such as `Query`. However, this allows catching errors on authorization extractors even in places where authorization is optional. Change-Id: I35f809d3adf27dbef0e7ee93dc1a7af178b7d014
Diffstat (limited to 'src/micropub')
-rw-r--r-- | src/micropub/mod.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/micropub/mod.rs b/src/micropub/mod.rs index 621d4f9..719fbf0 100644 --- a/src/micropub/mod.rs +++ b/src/micropub/mod.rs @@ -6,8 +6,9 @@ use crate::database::{MicropubChannel, Storage, StorageError}; use crate::indieauth::backend::AuthBackend; use crate::indieauth::User; use crate::micropub::util::form_to_mf2_json; -use axum::extract::{FromRef, Host, Query, State}; +use axum::extract::{FromRef, Query, State}; use axum::body::Body as BodyStream; +use axum_extra::extract::Host; use axum_extra::headers::ContentType; use axum::response::{IntoResponse, Response}; use axum_extra::TypedHeader; @@ -603,13 +604,13 @@ pub(crate) async fn post<D: Storage + 'static, A: AuthBackend>( #[tracing::instrument(skip(db))] pub(crate) async fn query<D: Storage, A: AuthBackend>( State(db): State<D>, - query: Option<Query<MicropubQuery>>, + query: Result<Query<MicropubQuery>, <Query<MicropubQuery> as axum::extract::FromRequestParts<()>>::Rejection>, Host(host): Host, user: User<A>, ) -> axum::response::Response { // We handle the invalid query case manually to return a // MicropubError instead of HTTP 422 - let query = if let Some(Query(query)) = query { + let query = if let Ok(Query(query)) = query { query } else { return MicropubError::from_static( @@ -771,7 +772,8 @@ mod tests { use super::FetchedPostContext; use kittybox_indieauth::{Scopes, Scope, TokenData}; - use axum::extract::{Host, State}; + use axum::extract::State; + use axum_extra::extract::Host; #[test] fn test_populate_reply_context() { @@ -927,7 +929,7 @@ mod tests { async fn test_query_foreign_url() { let res = super::query( State(crate::database::MemoryStorage::default()), - Some(axum::extract::Query(super::MicropubQuery::source( + Ok(axum::extract::Query(super::MicropubQuery::source( "https://aaronparecki.com/feeds/main", ))), Host("aaronparecki.com".to_owned()), |