Improve server macro documentation#3403
Conversation
|
Thanks for working on this! It looks like some unrelated changes to base path leaked into this PR. The two main fields that need documentation are the input and output fields. Since they effect both the encoding and the trait bounds on the inputs and outputs, it would be useful to include examples with the full server function, instead of just the encoding type. Here are a few examples of the bounds they imply: /// Setting the type to `StreamingJson` means you need to return something that implements From<JsonStream<T>>
/// where T implements serde::serialize and serde::de::DeserializeOwned
#[server(output = StreamingJson)]
pub async fn json_stream_fn() -> Result<JsonStream<String>, ServerFnError> {
todo!()
}
/// Setting the type to `StreamingText` means you need to return something that implements From<TextStream>
#[server(output = StreamingText)]
pub async fn text_stream_fn() -> Result<TextStream, ServerFnError> {
todo!()
}
/// Setting the type to `PostUrl` means you need to return something that implements Serialize and Deserialize.
/// This uses `serde_qs` which imposes the following requirements:
/// - Be less than 5 levels deep
/// - Contain no `serde(flatten)` attributes
#[server(output = PostUrl)]
pub async fn form_fn() -> Result<TextStream, ServerFnError> {
todo!()
} |
I have added the examples as requested @ealmloff 😄 |
packages/cli/src/config/app.rs
Outdated
| } | ||
|
|
||
| pub(crate) fn out_dir_default() -> PathBuf { | ||
| PathBuf::from("dist") |
There was a problem hiding this comment.
It may break the deployment script due to changing default build artifact directory. How about returning PathBuf for target/dx, which is current out directory described in dioxus_crate.rs:100
There was a problem hiding this comment.
@hackartists Hello!
I think this is the PR you're referring to #3393
And I already made that change there
Enhanced the #[server] macro documentation for improved clarity and usability. Key updates: