Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ealmloff committed Feb 28, 2024
1 parent 36ae7ec commit 4f3f3ad
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/fullstack/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use dioxus_ssr::{
use std::future::Future;
use std::sync::Arc;
use std::sync::RwLock;
use tokio::task::JoinHandle;
use tokio::task::block_in_place;
use tokio::task::JoinHandle;

use crate::prelude::*;
use dioxus_lib::prelude::*;
Expand Down
28 changes: 25 additions & 3 deletions packages/fullstack/src/server_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,36 @@ mod server_fn_impl {
/// Get the request that triggered:
/// - The initial SSR render if called from a ScopeState or ServerFn
/// - The server function to be called if called from a server function after the initial render
pub fn request_parts(&self) -> tokio::sync::RwLockReadGuard<'_, http::request::Parts> {
pub async fn request_parts(
&self,
) -> tokio::sync::RwLockReadGuard<'_, http::request::Parts> {
self.parts.read().await
}

/// Get the request that triggered:
/// - The initial SSR render if called from a ScopeState or ServerFn
/// - The server function to be called if called from a server function after the initial render
pub fn request_parts_blocking(
&self,
) -> tokio::sync::RwLockReadGuard<'_, http::request::Parts> {
self.parts.blocking_read()
}

/// Get the request that triggered:
/// - The initial SSR render if called from a ScopeState or ServerFn
/// - The server function to be called if called from a server function after the initial render
pub fn request_parts_mut(&self) -> tokio::sync::RwLockWriteGuard<'_, http::request::Parts> {
pub async fn request_parts_mut(
&self,
) -> tokio::sync::RwLockWriteGuard<'_, http::request::Parts> {
self.parts.write().await
}

/// Get the request that triggered:
/// - The initial SSR render if called from a ScopeState or ServerFn
/// - The server function to be called if called from a server function after the initial render
pub fn request_parts_mut_blocking(
&self,
) -> tokio::sync::RwLockWriteGuard<'_, http::request::Parts> {
self.parts.blocking_write()
}

Expand Down Expand Up @@ -239,6 +261,6 @@ impl<
type Rejection = R;

async fn from_request(req: &DioxusServerContext) -> Result<Self, Self::Rejection> {
Ok(I::from_request_parts(&mut req.request_parts_mut(), &()).await?)
Ok(I::from_request_parts(&mut req.request_parts_mut().await, &()).await?)
}
}

0 comments on commit 4f3f3ad

Please sign in to comment.