mirror of
https://github.com/adoyle0/leptos-use.git
synced 2025-02-02 10:54:15 -05:00
Fixed differing http versions
This commit is contained in:
parent
d6289cbf3c
commit
d44b9a292d
2 changed files with 17 additions and 7 deletions
|
@ -21,7 +21,8 @@ default-struct-builder = "0.5"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
gloo-timers = { version = "0.3.0", features = ["futures"] }
|
gloo-timers = { version = "0.3.0", features = ["futures"] }
|
||||||
gloo-utils = { version = "0.2.0" }
|
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"
|
js-sys = "0.3"
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
leptos = "0.6"
|
leptos = "0.6"
|
||||||
|
@ -104,13 +105,13 @@ features = [
|
||||||
]
|
]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
actix = ["dep:actix-web"]
|
actix = ["dep:actix-web", "dep:http0_2"]
|
||||||
axum = ["dep:leptos_axum"]
|
axum = ["dep:leptos_axum", "dep:http1"]
|
||||||
docs = []
|
docs = []
|
||||||
math = ["num"]
|
math = ["num"]
|
||||||
prost = ["base64", "dep:prost"]
|
prost = ["base64", "dep:prost"]
|
||||||
serde = ["dep:serde", "serde_json"]
|
serde = ["dep:serde", "serde_json"]
|
||||||
ssr = ["dep:http"]
|
ssr = []
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
all-features = true
|
all-features = true
|
||||||
|
|
|
@ -43,9 +43,18 @@ pub fn use_cookie(cookie_name: &str) -> Option<Cookie<'static>> {
|
||||||
let cookies;
|
let cookies;
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
{
|
{
|
||||||
use http::HeaderValue;
|
|
||||||
use leptos::expect_context;
|
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;
|
let headers;
|
||||||
#[cfg(feature = "actix")]
|
#[cfg(feature = "actix")]
|
||||||
{
|
{
|
||||||
|
@ -53,10 +62,10 @@ pub fn use_cookie(cookie_name: &str) -> Option<Cookie<'static>> {
|
||||||
}
|
}
|
||||||
#[cfg(feature = "axum")]
|
#[cfg(feature = "axum")]
|
||||||
{
|
{
|
||||||
headers = expect_context::<http::request::Parts>().headers;
|
headers = expect_context::<http1::request::Parts>().headers;
|
||||||
}
|
}
|
||||||
cookies = headers
|
cookies = headers
|
||||||
.get(http::header::COOKIE)
|
.get(COOKIE)
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or_else(|| HeaderValue::from_static(""))
|
.unwrap_or_else(|| HeaderValue::from_static(""))
|
||||||
.to_str()
|
.to_str()
|
||||||
|
|
Loading…
Add table
Reference in a new issue