fix: remove unnecessary default features on axum in server_fns to support running Axum in a WASM environment (#2270)

This commit is contained in:
Sam Judelson 2024-02-07 11:08:48 -05:00 committed by GitHub
parent a903e19eb2
commit 1b55227d10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 14 additions and 10 deletions

View file

@ -14,7 +14,7 @@ axum = { version = "0.7", default-features = false, features = [
futures = "0.3" futures = "0.3"
http-body-util = "0.1" http-body-util = "0.1"
leptos = { workspace = true, features = ["ssr"] } leptos = { workspace = true, features = ["ssr"] }
server_fn = { workspace = true, features = ["axum"] } server_fn = { workspace = true, features = ["axum-no-default"] }
leptos_macro = { workspace = true, features = ["axum"] } leptos_macro = { workspace = true, features = ["axum"] }
leptos_meta = { workspace = true, features = ["ssr"] } leptos_meta = { workspace = true, features = ["ssr"] }
leptos_router = { workspace = true, features = ["ssr"] } leptos_router = { workspace = true, features = ["ssr"] }

View file

@ -27,7 +27,7 @@ once_cell = "1"
actix-web = { version = "4", optional = true } actix-web = { version = "4", optional = true }
# axum # axum
axum = { version = "0.7", optional = true, features = ["multipart"] } axum = { version = "0.7", optional = true, default-features = false, features = ["multipart"] }
tower = { version = "0.4", optional = true } tower = { version = "0.4", optional = true }
tower-layer = { version = "0.3", optional = true } tower-layer = { version = "0.3", optional = true }
@ -75,7 +75,7 @@ url = "2"
default = ["json", "cbor"] default = ["json", "cbor"]
form-redirects = [] form-redirects = []
actix = ["ssr", "dep:actix-web", "dep:send_wrapper"] actix = ["ssr", "dep:actix-web", "dep:send_wrapper"]
axum = [ axum-no-default = [
"ssr", "ssr",
"dep:axum", "dep:axum",
"dep:hyper", "dep:hyper",
@ -83,6 +83,10 @@ axum = [
"dep:tower", "dep:tower",
"dep:tower-layer", "dep:tower-layer",
] ]
axum = [
"axum/default",
"axum-no-default",
]
browser = [ browser = [
"dep:gloo-net", "dep:gloo-net",
"dep:js-sys", "dep:js-sys",

View file

@ -117,7 +117,7 @@ pub mod response;
#[cfg(feature = "actix")] #[cfg(feature = "actix")]
#[doc(hidden)] #[doc(hidden)]
pub use ::actix_web as actix_export; pub use ::actix_web as actix_export;
#[cfg(feature = "axum")] #[cfg(feature = "axum-no-default")]
#[doc(hidden)] #[doc(hidden)]
pub use ::axum as axum_export; pub use ::axum as axum_export;
use client::Client; use client::Client;
@ -456,7 +456,7 @@ impl<Req: 'static, Res: 'static> inventory::Collect
} }
/// Axum integration. /// Axum integration.
#[cfg(feature = "axum")] #[cfg(feature = "axum-no-default")]
pub mod axum { pub mod axum {
use crate::{ use crate::{
middleware::{BoxedService, Service}, middleware::{BoxedService, Service},

View file

@ -26,7 +26,7 @@ pub trait Service<Request, Response> {
) -> Pin<Box<dyn Future<Output = Response> + Send>>; ) -> Pin<Box<dyn Future<Output = Response> + Send>>;
} }
#[cfg(feature = "axum")] #[cfg(feature = "axum-no-default")]
mod axum { mod axum {
use super::{BoxedService, Service}; use super::{BoxedService, Service};
use crate::{response::Res, ServerFnError}; use crate::{response::Res, ServerFnError};

View file

@ -7,7 +7,7 @@ use std::{borrow::Cow, future::Future};
#[cfg(feature = "actix")] #[cfg(feature = "actix")]
pub mod actix; pub mod actix;
/// Request types for Axum. /// Request types for Axum.
#[cfg(feature = "axum")] #[cfg(feature = "axum-no-default")]
pub mod axum; pub mod axum;
/// Request types for the browser. /// Request types for the browser.
#[cfg(feature = "browser")] #[cfg(feature = "browser")]

View file

@ -5,7 +5,7 @@ pub mod actix;
#[cfg(feature = "browser")] #[cfg(feature = "browser")]
pub mod browser; pub mod browser;
/// Response types for Axum. /// Response types for Axum.
#[cfg(feature = "axum")] #[cfg(feature = "axum-no-default")]
pub mod http; pub mod http;
/// Response types for [`reqwest`]. /// Response types for [`reqwest`].
#[cfg(feature = "reqwest")] #[cfg(feature = "reqwest")]

View file

@ -434,7 +434,7 @@ pub fn server_macro_impl(
quote! { quote! {
#server_fn_path::request::BrowserMockReq #server_fn_path::request::BrowserMockReq
} }
} else if cfg!(feature = "axum") { } else if cfg!(feature = "axum-no-default") {
quote! { quote! {
#server_fn_path::axum_export::http::Request<#server_fn_path::axum_export::body::Body> #server_fn_path::axum_export::http::Request<#server_fn_path::axum_export::body::Body>
} }
@ -458,7 +458,7 @@ pub fn server_macro_impl(
quote! { quote! {
#server_fn_path::response::BrowserMockRes #server_fn_path::response::BrowserMockRes
} }
} else if cfg!(feature = "axum") { } else if cfg!(feature = "axum-no-default") {
quote! { quote! {
#server_fn_path::axum_export::http::Response<#server_fn_path::axum_export::body::Body> #server_fn_path::axum_export::http::Response<#server_fn_path::axum_export::body::Body>
} }