mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
parent
aa977001c1
commit
4809cf473e
3 changed files with 25 additions and 10 deletions
|
@ -1215,13 +1215,18 @@ where
|
|||
let mode = listing.mode();
|
||||
|
||||
for method in listing.methods() {
|
||||
let additional_context = additional_context.clone();
|
||||
let additional_context_and_method = move || {
|
||||
provide_context(method);
|
||||
additional_context();
|
||||
};
|
||||
router = if let Some(static_mode) = listing.static_mode() {
|
||||
router.route(
|
||||
path,
|
||||
static_route(
|
||||
options.clone(),
|
||||
app_fn.clone(),
|
||||
additional_context.clone(),
|
||||
additional_context_and_method.clone(),
|
||||
method,
|
||||
static_mode,
|
||||
),
|
||||
|
@ -1233,7 +1238,7 @@ where
|
|||
SsrMode::OutOfOrder => {
|
||||
render_app_to_stream_with_context(
|
||||
options.clone(),
|
||||
additional_context.clone(),
|
||||
additional_context_and_method.clone(),
|
||||
app_fn.clone(),
|
||||
method,
|
||||
)
|
||||
|
@ -1241,7 +1246,7 @@ where
|
|||
SsrMode::PartiallyBlocked => {
|
||||
render_app_to_stream_with_context_and_replace_blocks(
|
||||
options.clone(),
|
||||
additional_context.clone(),
|
||||
additional_context_and_method.clone(),
|
||||
app_fn.clone(),
|
||||
method,
|
||||
true,
|
||||
|
@ -1250,14 +1255,14 @@ where
|
|||
SsrMode::InOrder => {
|
||||
render_app_to_stream_in_order_with_context(
|
||||
options.clone(),
|
||||
additional_context.clone(),
|
||||
additional_context_and_method.clone(),
|
||||
app_fn.clone(),
|
||||
method,
|
||||
)
|
||||
}
|
||||
SsrMode::Async => render_app_async_with_context(
|
||||
options.clone(),
|
||||
additional_context.clone(),
|
||||
additional_context_and_method.clone(),
|
||||
app_fn.clone(),
|
||||
method,
|
||||
),
|
||||
|
|
|
@ -1615,6 +1615,11 @@ where
|
|||
let path = listing.path();
|
||||
|
||||
for method in listing.methods() {
|
||||
let cx_with_state = cx_with_state.clone();
|
||||
let cx_with_state_and_method = move || {
|
||||
provide_context(method);
|
||||
cx_with_state();
|
||||
};
|
||||
router = if let Some(static_mode) = listing.static_mode() {
|
||||
#[cfg(feature = "default")]
|
||||
{
|
||||
|
@ -1623,7 +1628,7 @@ where
|
|||
path,
|
||||
LeptosOptions::from_ref(options),
|
||||
app_fn.clone(),
|
||||
cx_with_state.clone(),
|
||||
cx_with_state_and_method.clone(),
|
||||
method,
|
||||
static_mode,
|
||||
)
|
||||
|
@ -1643,7 +1648,7 @@ where
|
|||
SsrMode::OutOfOrder => {
|
||||
let s = render_app_to_stream_with_context(
|
||||
LeptosOptions::from_ref(options),
|
||||
cx_with_state.clone(),
|
||||
cx_with_state_and_method.clone(),
|
||||
app_fn.clone(),
|
||||
);
|
||||
match method {
|
||||
|
@ -1657,7 +1662,7 @@ where
|
|||
SsrMode::PartiallyBlocked => {
|
||||
let s = render_app_to_stream_with_context_and_replace_blocks(
|
||||
LeptosOptions::from_ref(options),
|
||||
cx_with_state.clone(),
|
||||
cx_with_state_and_method.clone(),
|
||||
app_fn.clone(),
|
||||
true
|
||||
);
|
||||
|
@ -1672,7 +1677,7 @@ where
|
|||
SsrMode::InOrder => {
|
||||
let s = render_app_to_stream_in_order_with_context(
|
||||
LeptosOptions::from_ref(options),
|
||||
cx_with_state.clone(),
|
||||
cx_with_state_and_method.clone(),
|
||||
app_fn.clone(),
|
||||
);
|
||||
match method {
|
||||
|
@ -1686,7 +1691,7 @@ where
|
|||
SsrMode::Async => {
|
||||
let s = render_app_async_with_context(
|
||||
LeptosOptions::from_ref(options),
|
||||
cx_with_state.clone(),
|
||||
cx_with_state_and_method.clone(),
|
||||
app_fn.clone(),
|
||||
);
|
||||
match method {
|
||||
|
|
|
@ -410,6 +410,11 @@ impl RouteContext {
|
|||
pub fn outlet(&self) -> impl IntoView {
|
||||
(self.inner.outlet)()
|
||||
}
|
||||
|
||||
/// The http method used to navigate to this route. Defaults to [`Method::Get`] when unavailable like in client side routing
|
||||
pub fn method(&self) -> Method {
|
||||
use_context().unwrap_or_default()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct RouteContextInner {
|
||||
|
|
Loading…
Reference in a new issue