diff --git a/Cargo.toml b/Cargo.toml index e32940e18..3b36bb5e3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ members = [ "packages/rsx-rosetta", "packages/signals", "packages/hot-reload", + "packages/server", "docs/guide", ] diff --git a/packages/server/Cargo.toml b/packages/server/Cargo.toml new file mode 100644 index 000000000..13704574b --- /dev/null +++ b/packages/server/Cargo.toml @@ -0,0 +1,21 @@ +[package] +name = "server" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +server_fn = { version = "0.2.4", features = ["stable"] } + +# warp +warp = { version = "0.3.3", optional = true } + +# axum +axum = { version = "0.6.1", optional = true, features = ["ws"] } + +# salvo +salvo = { version = "0.37.7", optional = true, features = ["ws"] } +serde = "1.0.159" + +dioxus = { path = "../dioxus", version = "^0.3.0" } \ No newline at end of file diff --git a/packages/server/server_macro/Cargo.toml b/packages/server/server_macro/Cargo.toml new file mode 100644 index 000000000..6e8c69b46 --- /dev/null +++ b/packages/server/server_macro/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "server_macro" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/packages/server/server_macro/src/lib.rs b/packages/server/server_macro/src/lib.rs new file mode 100644 index 000000000..439a9e7b2 --- /dev/null +++ b/packages/server/server_macro/src/lib.rs @@ -0,0 +1,67 @@ +/// Declares that a function is a [server function](leptos_server). 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 +/// are enabled), it will instead make a network request to the server. +/// +/// You can specify one, two, or three arguments to the server function: +/// 1. **Required**: A type name that will be used to identify and register the server function +/// (e.g., `MyServerFn`). +/// 2. *Optional*: A URL prefix at which the function will be mounted when it’s registered +/// (e.g., `"/api"`). Defaults to `"/"`. +/// 3. *Optional*: either `"Cbor"` (specifying that it should use the binary `cbor` format for +/// serialization) or `"Url"` (specifying that it should be use a URL-encoded form-data string). +/// Defaults to `"Url"`. If you want to use this server function to power a `