about summary refs log tree commit diff
path: root/src/micropub/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/micropub/mod.rs')
-rw-r--r--src/micropub/mod.rs12
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()),