Skip to content

Commit c04d2d3

Browse files
committed
update to new attributes
1 parent 1dae2fb commit c04d2d3

5 files changed

Lines changed: 16 additions & 16 deletions

File tree

Bare-Bones/AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ dioxus = { version = "0.7.0-rc.4", features = ["fullstack"] }
244244

245245
## Server Functions
246246

247-
Use the `#[server]` macro to define an `async` function that will only run on the server. On the server, this macro generates an API endpoint. On the client, it generates a function that makes an HTTP request to that endpoint.
247+
Use the `#[post]` / `#[get]` macros to define an `async` function that will only run on the server. On the server, this macro generates an API endpoint. On the client, it generates a function that makes an HTTP request to that endpoint.
248248

249249
```rust
250-
#[server]
251-
async fn double_server(number: i32) -> Result<i32, ServerFnError> {
250+
#[post("/api/double/:path/&query")]
251+
async fn double_server(number: i32, path: String, query: i32) -> Result<i32, ServerFnError> {
252252
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
253253
Ok(number * 2)
254254
}

Bare-Bones/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ fn App() -> Element {
3030
document::Link { rel: "stylesheet", href: MAIN_CSS } {% if is_tailwind -%}
3131
document::Link { rel: "stylesheet", href: TAILWIND_CSS } {%- endif %}
3232
{% if is_router -%} Router::<Route> {}
33-
{%- else -%}
33+
{%- else -%}
3434
Hero {}
3535
{% if is_fullstack -%} Echo {} {%- endif %}
36-
{%- endif %}
36+
{%- endif %}
3737
}
3838
}
3939

@@ -140,7 +140,7 @@ fn Echo() -> Element {
140140
}
141141

142142
/// Echo the user input on the server.
143-
#[server(EchoServer)]
143+
#[post("/api/echo")]
144144
async fn echo_server(input: String) -> Result<String, ServerFnError> {
145145
Ok(input)
146146
}

Jumpstart/AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ dioxus = { version = "0.7.0-rc.4", features = ["fullstack"] }
244244

245245
## Server Functions
246246

247-
Use the `#[server]` macro to define an `async` function that will only run on the server. On the server, this macro generates an API endpoint. On the client, it generates a function that makes an HTTP request to that endpoint.
247+
Use the `#[post]` / `#[get]` macros to define an `async` function that will only run on the server. On the server, this macro generates an API endpoint. On the client, it generates a function that makes an HTTP request to that endpoint.
248248

249249
```rust
250-
#[server]
251-
async fn double_server(number: i32) -> Result<i32, ServerFnError> {
250+
#[post("/api/double/:path/&query")]
251+
async fn double_server(number: i32, path: String, query: i32) -> Result<i32, ServerFnError> {
252252
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
253253
Ok(number * 2)
254254
}

Jumpstart/src/components/echo.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const ECHO_CSS: Asset = asset!("/assets/styling/echo.css");
77
pub fn Echo() -> Element {
88
// use_signal is a hook. Hooks in dioxus must be run in a consistent order every time the component is rendered.
99
// That means they can't be run inside other hooks, async blocks, if statements, or loops.
10-
//
10+
//
1111
// use_signal is a hook that creates a state for the component. It takes a closure that returns the initial value of the state.
1212
// The state is automatically tracked and will rerun any other hooks or components that read it whenever it changes.
1313
let mut response = use_signal(|| String::new());
@@ -47,13 +47,13 @@ pub fn Echo() -> Element {
4747
}
4848

4949
// Server functions let us define public APIs on the server that can be called like a normal async function from the client.
50-
// Each server function needs to be annotated with the `#[server]` attribute, accept and return serializable types, and return
50+
// Each server function needs to be annotated with the `#[post]`/`#[get]` attributes, accept and return serializable types, and return
5151
// a `Result` with the error type [`ServerFnError`].
5252
//
5353
// When the server function is called from the client, it will just serialize the arguments, call the API, and deserialize the
5454
// response.
55-
#[server]
56-
async fn echo_server(input: String) -> Result<String, ServerFnError> {
55+
#[post("/api/echo")]
56+
async fn echo_server(input: String) -> Result<String> {
5757
// The body of server function like this comment are only included on the server. If you have any server-only logic like
5858
// database queries, you can put it here. Any imports for the server function should either be imported inside the function
5959
// or imported under a `#[cfg(feature = "server")]` block.

Workspace/AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,11 @@ dioxus = { version = "0.7.0-rc.4", features = ["fullstack"] }
244244

245245
## Server Functions
246246

247-
Use the `#[server]` macro to define an `async` function that will only run on the server. On the server, this macro generates an API endpoint. On the client, it generates a function that makes an HTTP request to that endpoint.
247+
Use the `#[post]` / `#[get]` macros to define an `async` function that will only run on the server. On the server, this macro generates an API endpoint. On the client, it generates a function that makes an HTTP request to that endpoint.
248248

249249
```rust
250-
#[server]
251-
async fn double_server(number: i32) -> Result<i32, ServerFnError> {
250+
#[post("/api/double/:path/&query")]
251+
async fn double_server(number: i32, path: String, query: i32) -> Result<i32, ServerFnError> {
252252
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
253253
Ok(number * 2)
254254
}

0 commit comments

Comments
 (0)