mirror of
https://github.com/leptos-rs/leptos.git
synced 2025-12-27 09:54:41 -05:00
forward server fn visibility
This commit is contained in:
@@ -35,6 +35,7 @@ pub trait Client<E> {
|
||||
) -> impl Future<Output = Result<Self::Response, E>> + Send;
|
||||
|
||||
/// Opens a websocket connection to the server.
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn open_websocket(
|
||||
path: &str,
|
||||
) -> impl Future<
|
||||
@@ -262,7 +263,6 @@ pub mod reqwest {
|
||||
websocket_server_url = format!("wss://{}", postfix);
|
||||
}
|
||||
let url = format!("{}{}", websocket_server_url, path);
|
||||
println!("url: {}", url);
|
||||
let (ws_stream, _) =
|
||||
tokio_tungstenite::connect_async(url).await.map_err(|e| {
|
||||
E::from_server_fn_error(ServerFnErrorErr::Request(
|
||||
|
||||
@@ -170,6 +170,13 @@ use std::{
|
||||
#[doc(hidden)]
|
||||
pub use xxhash_rust;
|
||||
|
||||
type ServerFnServerRequest<Fn> = <<Fn as ServerFn>::Server as crate::Server<
|
||||
<Fn as ServerFn>::Error,
|
||||
>>::Request;
|
||||
type ServerFnServerResponse<Fn> = <<Fn as ServerFn>::Server as crate::Server<
|
||||
<Fn as ServerFn>::Error,
|
||||
>>::Response;
|
||||
|
||||
/// Defines a function that runs only on the server, but can be called from the server or the client.
|
||||
///
|
||||
/// The type for which `ServerFn` is implemented is actually the type of the arguments to the function,
|
||||
@@ -240,8 +247,8 @@ pub trait ServerFn: Send + Sized {
|
||||
fn middlewares() -> Vec<
|
||||
Arc<
|
||||
dyn Layer<
|
||||
<Self::Server as crate::Server<Self::Error>>::Request,
|
||||
<Self::Server as crate::Server<Self::Error>>::Response,
|
||||
ServerFnServerRequest<Self>,
|
||||
ServerFnServerResponse<Self>,
|
||||
>,
|
||||
>,
|
||||
> {
|
||||
@@ -255,10 +262,8 @@ pub trait ServerFn: Send + Sized {
|
||||
|
||||
#[doc(hidden)]
|
||||
fn run_on_server(
|
||||
req: <Self::Server as crate::Server<Self::Error>>::Request,
|
||||
) -> impl Future<
|
||||
Output = <Self::Server as crate::Server<Self::Error>>::Response,
|
||||
> + Send {
|
||||
req: ServerFnServerRequest<Self>,
|
||||
) -> impl Future<Output = ServerFnServerResponse<Self>> + Send {
|
||||
// Server functions can either be called by a real Client,
|
||||
// or directly by an HTML <form>. If they're accessed by a <form>, default to
|
||||
// redirecting back to the Referer.
|
||||
|
||||
@@ -131,7 +131,6 @@ where
|
||||
futures::select! {
|
||||
incoming = response_sink_rx.next() => {
|
||||
let Some(incoming) = incoming else {
|
||||
println!("incoming is none");
|
||||
break;
|
||||
};
|
||||
match incoming {
|
||||
@@ -141,7 +140,6 @@ where
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
println!("ran into error: {err:?}");
|
||||
_ = response_stream_tx.start_send(Err(err));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ where
|
||||
#[cfg(feature = "axum")]
|
||||
{
|
||||
use axum::extract::ws::Message;
|
||||
use axum::extract::FromRequest;
|
||||
use futures::FutureExt;
|
||||
|
||||
let upgrade =
|
||||
|
||||
@@ -105,6 +105,7 @@ where
|
||||
) -> Result<impl Stream<Item = Result<Bytes, E>> + Send + 'static, E>;
|
||||
|
||||
/// Attempts to convert the body of the request into a websocket handle.
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn try_into_websocket(
|
||||
self,
|
||||
) -> impl Future<
|
||||
|
||||
Reference in New Issue
Block a user