Fix server function warning with default features (#4453)
* fix server function warning with default features * document and hide mock client * fix clippy * more clippy fixes * fix formatting
This commit is contained in:
1 parent
86086477d0
commit
18fe6de9a0
7 files changed
+181
-6
No files matched your search
@@ -206,11 +206,23 @@ use syn::{__private::ToTokens, parse_quote};
|
||||
#[proc_macro_attribute]
|
||||
pub fn server(args: proc_macro::TokenStream, body: TokenStream) -> TokenStream {
|
||||
// If there is no input codec, use json as the default
|
||||
let parsed = match ServerFnCall::parse("/api", args.into(), body.into()) {
|
||||
#[allow(unused_mut)]
|
||||
let mut parsed = match ServerFnCall::parse("/api", args.into(), body.into()) {
|
||||
Ok(parsed) => parsed,
|
||||
Err(e) => return e.to_compile_error().into(),
|
||||
};
|
||||
|
||||
#[cfg(not(any(feature = "browser", feature = "reqwest")))]
|
||||
{
|
||||
let client = &mut parsed.get_args_mut().client;
|
||||
// If no client is enabled, use the mock client
|
||||
if client.is_none() {
|
||||
*client = Some(parse_quote!(
|
||||
dioxus::fullstack::mock_client::MockServerFnClient
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
parsed
|
||||
.default_protocol(Some(
|
||||
parse_quote!(server_fn::Http<server_fn::codec::Json, server_fn::codec::Json>),
|
||||
|
||||
Reference in new issue
Block a user