Skip to content

Commit

Permalink
Merge pull request #70 from rakshith-ravi/feature/version-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
maccesch committed Jan 27, 2024
2 parents c9c269b + ee930bb commit 352203b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
15 changes: 8 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ 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.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 }
Expand All @@ -36,7 +37,7 @@ wasm-bindgen = "0.2.88"
wasm-bindgen-futures = "0.4"

[dependencies.web-sys]
version = "0.3.67"
version = "0.3"
features = [
"AddEventListenerOptions",
"BinaryType",
Expand Down Expand Up @@ -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
15 changes: 12 additions & 3 deletions src/use_cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,29 @@ pub fn use_cookie(cookie_name: &str) -> Option<Cookie<'static>> {
let cookies;
#[cfg(feature = "ssr")]
{
use http::HeaderValue;
use leptos::expect_context;

#[cfg(feature = "actix")]
const COOKIE: http0_2::HeaderName = http0_2::header::COOKIE;
#[cfg(feature = "axum")]
const COOKIE: http1::HeaderName = http1::header::COOKIE;

#[cfg(feature = "actix")]
type HeaderValue = http0_2::HeaderValue;
#[cfg(feature = "axum")]
type HeaderValue = http1::HeaderValue;

let headers;
#[cfg(feature = "actix")]
{
headers = expect_context::<actix_web::HttpRequest>().headers().clone();
}
#[cfg(feature = "axum")]
{
headers = expect_context::<http::request::Parts>().headers;
headers = expect_context::<http1::request::Parts>().headers;
}
cookies = headers
.get(http::header::COOKIE)
.get(COOKIE)
.cloned()
.unwrap_or_else(|| HeaderValue::from_static(""))
.to_str()
Expand Down

0 comments on commit 352203b

Please sign in to comment.