diff --git a/Cargo.toml b/Cargo.toml index 17d30d5..4882769 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,9 @@ guards = ["tower", "futures-core", "pin-project-lite"] serde = ["dep:serde", "dep:serde_json"] [dependencies] -axum = { version = "0.7", default-features = false } +axum-core = "0.4" +http = { version = "1.0.0", default-features = false } +async-trait = "0.1.74" # Optional dependencies required for the `guards` feature. tower = { version = "0.4", default-features = false, optional = true } diff --git a/src/extractors.rs b/src/extractors.rs index 482f49b..7e7304f 100644 --- a/src/extractors.rs +++ b/src/extractors.rs @@ -1,6 +1,8 @@ //! Axum extractors for htmx request headers. -use axum::{extract::FromRequestParts, http::request::Parts}; +use async_trait::async_trait; +use axum_core::extract::FromRequestParts; +use http::request::Parts; use crate::{ HX_BOOSTED, HX_CURRENT_URL, HX_HISTORY_RESTORE_REQUEST, HX_PROMPT, HX_REQUEST, HX_TARGET, @@ -19,7 +21,7 @@ use crate::{ #[derive(Debug, Clone, Copy)] pub struct HxBoosted(pub bool); -#[axum::async_trait] +#[async_trait] impl FromRequestParts for HxBoosted where S: Send + Sync, @@ -45,7 +47,7 @@ where #[derive(Debug, Clone)] pub struct HxCurrentUrl(pub Option); -#[axum::async_trait] +#[async_trait] impl FromRequestParts for HxCurrentUrl where S: Send + Sync, @@ -70,7 +72,7 @@ where #[derive(Debug, Clone, Copy)] pub struct HxHistoryRestoreRequest(pub bool); -#[axum::async_trait] +#[async_trait] impl FromRequestParts for HxHistoryRestoreRequest where S: Send + Sync, @@ -96,7 +98,7 @@ where #[derive(Debug, Clone)] pub struct HxPrompt(pub Option); -#[axum::async_trait] +#[async_trait] impl FromRequestParts for HxPrompt where S: Send + Sync, @@ -124,7 +126,7 @@ where #[derive(Debug, Clone, Copy)] pub struct HxRequest(pub bool); -#[axum::async_trait] +#[async_trait] impl FromRequestParts for HxRequest where S: Send + Sync, @@ -151,7 +153,7 @@ where #[derive(Debug, Clone)] pub struct HxTarget(pub Option); -#[axum::async_trait] +#[async_trait] impl FromRequestParts for HxTarget where S: Send + Sync, @@ -180,7 +182,7 @@ where #[derive(Debug, Clone)] pub struct HxTriggerName(pub Option); -#[axum::async_trait] +#[async_trait] impl FromRequestParts for HxTriggerName where S: Send + Sync, @@ -209,7 +211,7 @@ where #[derive(Debug, Clone)] pub struct HxTrigger(pub Option); -#[axum::async_trait] +#[async_trait] impl FromRequestParts for HxTrigger where S: Send + Sync, diff --git a/src/guard.rs b/src/guard.rs index 38d078c..d4a8421 100644 --- a/src/guard.rs +++ b/src/guard.rs @@ -7,11 +7,8 @@ use std::{ task::{Context, Poll}, }; -use axum::{ - http::{header::LOCATION, Request, StatusCode}, - response::Response, -}; use futures_core::ready; +use http::{header::LOCATION, response::Response, Request, StatusCode}; use pin_project_lite::pin_project; use tower::{Layer, Service}; diff --git a/src/responders.rs b/src/responders.rs index e92a3c9..99aef61 100644 --- a/src/responders.rs +++ b/src/responders.rs @@ -2,10 +2,8 @@ use std::convert::Infallible; -use axum::{ - http::{header::InvalidHeaderValue, HeaderValue, StatusCode, Uri}, - response::{IntoResponse, IntoResponseParts, ResponseParts}, -}; +use axum_core::response::{IntoResponse, IntoResponseParts, ResponseParts}; +use http::{header::InvalidHeaderValue, HeaderValue, StatusCode, Uri}; use crate::headers; @@ -392,7 +390,7 @@ impl From for HxError { } impl IntoResponse for HxError { - fn into_response(self) -> axum::response::Response { + fn into_response(self) -> axum_core::response::Response { match self { Self::InvalidHeaderValue(_) => { (StatusCode::INTERNAL_SERVER_ERROR, "invalid header value").into_response() diff --git a/src/responders/serde.rs b/src/responders/serde.rs index bc05290..7bfb875 100644 --- a/src/responders/serde.rs +++ b/src/responders/serde.rs @@ -1,9 +1,7 @@ use std::collections::HashMap; -use axum::{ - http::{HeaderValue, Uri}, - response::{IntoResponseParts, ResponseParts}, -}; +use axum_core::response::{IntoResponseParts, ResponseParts}; +use http::{HeaderValue, Uri}; use serde::Serialize; use serde_json::Value;