|
@@ -2,7 +2,7 @@ use proc_macro::TokenStream;
|
|
|
use quote::ToTokens;
|
|
|
use server_fn_macro::*;
|
|
|
|
|
|
-/// Declares that a function is a [server function](dioxus_server). This means that
|
|
|
+/// Declares that a function is a [server function](dioxus_fullstack). This means that
|
|
|
/// its body will only run on the server, i.e., when the `ssr` feature is enabled.
|
|
|
///
|
|
|
/// If you call a server function from the client (i.e., when the `csr` or `hydrate` features
|
|
@@ -20,12 +20,12 @@ use server_fn_macro::*;
|
|
|
/// using Get instead of Post methods, the encoding must be `"GetCbor"` or `"GetJson"`.
|
|
|
///
|
|
|
/// The server function itself can take any number of arguments, each of which should be serializable
|
|
|
-/// and deserializable with `serde`. Optionally, its first argument can be a [DioxusServerContext](https::/docs.rs/dioxus-server/latest/dixous_server/prelude/struct.DioxusServerContext.html),
|
|
|
+/// and deserializable with `serde`. Optionally, its first argument can be a [DioxusServerContext](https::/docs.rs/dioxus-fullstack/latest/dixous_server/prelude/struct.DioxusServerContext.html),
|
|
|
/// which will be injected *on the server side.* This can be used to inject the raw HTTP request or other
|
|
|
/// server-side context into the server function.
|
|
|
///
|
|
|
/// ```ignore
|
|
|
-/// # use dioxus_server::prelude::*; use serde::{Serialize, Deserialize};
|
|
|
+/// # use dioxus_fullstack::prelude::*; use serde::{Serialize, Deserialize};
|
|
|
/// # #[derive(Serialize, Deserialize)]
|
|
|
/// # pub struct Post { }
|
|
|
/// #[server(ReadPosts, "/api")]
|
|
@@ -51,20 +51,20 @@ use server_fn_macro::*;
|
|
|
/// They are serialized as an `application/x-www-form-urlencoded`
|
|
|
/// form data using [`serde_urlencoded`](https://docs.rs/serde_urlencoded/latest/serde_urlencoded/) or as `application/cbor`
|
|
|
/// using [`cbor`](https://docs.rs/cbor/latest/cbor/).
|
|
|
-/// - **The [DioxusServerContext](https::/docs.rs/dioxus-server/latest/dixous_server/prelude/struct.DioxusServerContext.html) comes from the server.** Optionally, the first argument of a server function
|
|
|
-/// can be a [DioxusServerContext](https::/docs.rs/dioxus-server/latest/dixous_server/prelude/struct.DioxusServerContext.html). This scope can be used to inject dependencies like the HTTP request
|
|
|
+/// - **The [DioxusServerContext](https::/docs.rs/dioxus-fullstack/latest/dixous_server/prelude/struct.DioxusServerContext.html) comes from the server.** Optionally, the first argument of a server function
|
|
|
+/// can be a [DioxusServerContext](https::/docs.rs/dioxus-fullstack/latest/dixous_server/prelude/struct.DioxusServerContext.html). This scope can be used to inject dependencies like the HTTP request
|
|
|
/// or response or other server-only dependencies, but it does *not* have access to reactive state that exists in the client.
|
|
|
#[proc_macro_attribute]
|
|
|
pub fn server(args: proc_macro::TokenStream, s: TokenStream) -> TokenStream {
|
|
|
let context = ServerContext {
|
|
|
ty: syn::parse_quote!(DioxusServerContext),
|
|
|
- path: syn::parse_quote!(::dioxus_server::prelude::DioxusServerContext),
|
|
|
+ path: syn::parse_quote!(::dioxus_fullstack::prelude::DioxusServerContext),
|
|
|
};
|
|
|
match server_macro_impl(
|
|
|
args.into(),
|
|
|
s.into(),
|
|
|
Some(context),
|
|
|
- Some(syn::parse_quote!(::dioxus_server::prelude::server_fn)),
|
|
|
+ Some(syn::parse_quote!(::dioxus_fullstack::prelude::server_fn)),
|
|
|
) {
|
|
|
Err(e) => e.to_compile_error().into(),
|
|
|
Ok(s) => s.to_token_stream().into(),
|