From d6289cbf3c34e7710745e3826e6a3af733c40b4f Mon Sep 17 00:00:00 2001 From: Rakshith Ravi Date: Sat, 27 Jan 2024 03:15:21 +0530 Subject: [PATCH 1/4] Upgraded to 0.6 :) --- Cargo.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 45b3bda2..a49a177f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,8 +24,8 @@ gloo-utils = { version = "0.2.0" } http = { version = "1", optional = true } js-sys = "0.3" lazy_static = "1" -leptos = "0.6.0-beta" -leptos_axum = { version = "0.6.0-beta", optional = true } +leptos = "0.6" +leptos_axum = { version = "0.6", optional = true } num = { version = "0.4", optional = true } paste = "1" prost = { version = "0.12", optional = true } @@ -36,7 +36,7 @@ wasm-bindgen = "0.2.88" wasm-bindgen-futures = "0.4" [dependencies.web-sys] -version = "0.3.67" +version = "0.3" features = [ "AddEventListenerOptions", "BinaryType", From d44b9a292df389c6bde9b7f77fc001360243c81e Mon Sep 17 00:00:00 2001 From: Rakshith Ravi Date: Sat, 27 Jan 2024 03:29:14 +0530 Subject: [PATCH 2/4] Fixed differing http versions --- Cargo.toml | 9 +++++---- src/use_cookie.rs | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a49a177f..8c1c3817 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,8 @@ default-struct-builder = "0.5" futures-util = "0.3" gloo-timers = { version = "0.3.0", features = ["futures"] } gloo-utils = { version = "0.2.0" } -http = { version = "1", optional = true } +http1 = { version = "1", optional = true, package = "http" } +http0_2 = { version = "0.2", optional = true, package = "http" } js-sys = "0.3" lazy_static = "1" leptos = "0.6" @@ -104,13 +105,13 @@ features = [ ] [features] -actix = ["dep:actix-web"] -axum = ["dep:leptos_axum"] +actix = ["dep:actix-web", "dep:http0_2"] +axum = ["dep:leptos_axum", "dep:http1"] docs = [] math = ["num"] prost = ["base64", "dep:prost"] serde = ["dep:serde", "serde_json"] -ssr = ["dep:http"] +ssr = [] [package.metadata.docs.rs] all-features = true diff --git a/src/use_cookie.rs b/src/use_cookie.rs index 5c32b58f..c4f89a89 100644 --- a/src/use_cookie.rs +++ b/src/use_cookie.rs @@ -43,8 +43,17 @@ pub fn use_cookie(cookie_name: &str) -> Option> { let cookies; #[cfg(feature = "ssr")] { - use http::HeaderValue; use leptos::expect_context; + + #[cfg(feature = "actix")] + const COOKIE: http0_2::HeaderValue = http0_2::header::COOKIE; + #[cfg(feature = "axum")] + const COOKIE: http1::HeaderValue = http1::header::COOKIE; + + #[cfg(feature = "actix")] + type HeaderValue = http0_2::HeaderValue; + #[cfg(feature = "axum")] + type HeaderValue = http1::HeaderValue; let headers; #[cfg(feature = "actix")] @@ -53,10 +62,10 @@ pub fn use_cookie(cookie_name: &str) -> Option> { } #[cfg(feature = "axum")] { - headers = expect_context::().headers; + headers = expect_context::().headers; } cookies = headers - .get(http::header::COOKIE) + .get(COOKIE) .cloned() .unwrap_or_else(|| HeaderValue::from_static("")) .to_str() From 91f483c850ed854d0a70dfa09575a6f280051c51 Mon Sep 17 00:00:00 2001 From: Rakshith Ravi Date: Sat, 27 Jan 2024 03:30:30 +0530 Subject: [PATCH 3/4] Fixed formatting --- src/use_cookie.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/use_cookie.rs b/src/use_cookie.rs index c4f89a89..5745ab77 100644 --- a/src/use_cookie.rs +++ b/src/use_cookie.rs @@ -44,7 +44,7 @@ pub fn use_cookie(cookie_name: &str) -> Option> { #[cfg(feature = "ssr")] { use leptos::expect_context; - + #[cfg(feature = "actix")] const COOKIE: http0_2::HeaderValue = http0_2::header::COOKIE; #[cfg(feature = "axum")] From ee930bbabb5b42912b5f6ae46a1bf2834d97a12e Mon Sep 17 00:00:00 2001 From: Rakshith Ravi Date: Sat, 27 Jan 2024 03:35:29 +0530 Subject: [PATCH 4/4] Fixed typo --- src/use_cookie.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/use_cookie.rs b/src/use_cookie.rs index 5745ab77..1cec3888 100644 --- a/src/use_cookie.rs +++ b/src/use_cookie.rs @@ -46,9 +46,9 @@ pub fn use_cookie(cookie_name: &str) -> Option> { use leptos::expect_context; #[cfg(feature = "actix")] - const COOKIE: http0_2::HeaderValue = http0_2::header::COOKIE; + const COOKIE: http0_2::HeaderName = http0_2::header::COOKIE; #[cfg(feature = "axum")] - const COOKIE: http1::HeaderValue = http1::header::COOKIE; + const COOKIE: http1::HeaderName = http1::header::COOKIE; #[cfg(feature = "actix")] type HeaderValue = http0_2::HeaderValue;