From 3bd34f23367c11706d9c455a2a5d898a697ea62a Mon Sep 17 00:00:00 2001 From: Greg Johnston Date: Mon, 8 Jan 2024 22:00:07 -0500 Subject: [PATCH] chore: clear warnings --- examples/todo_app_sqlite_axum/Cargo.toml | 2 +- examples/todo_app_sqlite_axum/src/main.rs | 2 +- examples/todo_app_sqlite_axum/src/todo.rs | 6 +++--- integrations/axum/src/lib.rs | 6 +++--- router/src/components/form.rs | 16 +++------------- router/src/components/router.rs | 6 ++++-- 6 files changed, 15 insertions(+), 23 deletions(-) diff --git a/examples/todo_app_sqlite_axum/Cargo.toml b/examples/todo_app_sqlite_axum/Cargo.toml index 5e4d187d56..4d6e7f84ed 100644 --- a/examples/todo_app_sqlite_axum/Cargo.toml +++ b/examples/todo_app_sqlite_axum/Cargo.toml @@ -13,7 +13,7 @@ futures = "0.3" cfg-if = "1.0" http = "1.0" leptos = { path = "../../leptos", features = ["nightly"] } -server_fn = { path = "../../server_fn", features = ["url", "json"] } +server_fn = { path = "../../server_fn", features = ["serde-lite"] } leptos_axum = { path = "../../integrations/axum", optional = true } leptos_meta = { path = "../../meta", features = ["nightly"] } leptos_router = { path = "../../router", features = ["nightly"] } diff --git a/examples/todo_app_sqlite_axum/src/main.rs b/examples/todo_app_sqlite_axum/src/main.rs index 62631b84f2..a001e3f723 100644 --- a/examples/todo_app_sqlite_axum/src/main.rs +++ b/examples/todo_app_sqlite_axum/src/main.rs @@ -4,7 +4,7 @@ cfg_if! { if #[cfg(feature = "ssr")] { use leptos::*; use axum::{ - routing::{post, get}, + routing::get, extract::{State, Path}, http::Request, response::{IntoResponse, Response}, diff --git a/examples/todo_app_sqlite_axum/src/todo.rs b/examples/todo_app_sqlite_axum/src/todo.rs index a4dfbd5232..21a70b7779 100644 --- a/examples/todo_app_sqlite_axum/src/todo.rs +++ b/examples/todo_app_sqlite_axum/src/todo.rs @@ -4,6 +4,7 @@ use leptos::*; use leptos_meta::*; use leptos_router::*; use serde::{Deserialize, Serialize}; +use server_fn::codec::SerdeLite; #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] #[cfg_attr(feature = "ssr", derive(sqlx::FromRow))] @@ -26,8 +27,7 @@ cfg_if! { #[server(GetTodos, "/api")] pub async fn get_todos() -> Result, ServerFnError> { - use http::{header::SET_COOKIE, request::Parts, HeaderValue, StatusCode}; - use leptos_axum::ResponseOptions; + use http::request::Parts; // this is just an example of how to access server context injected in the handlers let req_parts = use_context::(); @@ -73,7 +73,7 @@ pub async fn add_todo(title: String) -> Result<(), ServerFnError> { } // The struct name and path prefix arguments are optional. -#[server] +#[server(output = SerdeLite)] pub async fn delete_todo(id: u16) -> Result<(), ServerFnError> { let mut conn = db().await?; diff --git a/integrations/axum/src/lib.rs b/integrations/axum/src/lib.rs index a7793c89e7..49fdb79c61 100644 --- a/integrations/axum/src/lib.rs +++ b/integrations/axum/src/lib.rs @@ -664,7 +664,7 @@ where let path = req.uri().path_and_query().unwrap().as_str(); let full_path = format!("http://leptos.dev{path}"); - let (req, req_parts) = generate_request_and_parts(req); + let (_, req_parts) = generate_request_and_parts(req); move || { provide_contexts(full_path, req_parts, default_res_options); app_fn().into_view() @@ -998,7 +998,7 @@ where spawn_task!(async move { let app = { let full_path = full_path.clone(); - let (req, req_parts) = generate_request_and_parts(req); + let (_, req_parts) = generate_request_and_parts(req); move || { provide_contexts( full_path, @@ -1128,7 +1128,7 @@ where spawn_task!(async move { let app = { let full_path = full_path.clone(); - let (req, req_parts) = generate_request_and_parts(req); + let (_, req_parts) = generate_request_and_parts(req); move || { provide_contexts( full_path, diff --git a/router/src/components/form.rs b/router/src/components/form.rs index f16d223242..d11edde10c 100644 --- a/router/src/components/form.rs +++ b/router/src/components/form.rs @@ -5,17 +5,10 @@ use crate::{ use leptos::{ html::form, logging::*, - server_fn::{ - client::Client, - codec::{Encoding, PostUrl}, - redirect::RedirectHook, - request::ClientReq, - ServerFn, - }, + server_fn::{client::Client, codec::PostUrl, request::ClientReq, ServerFn}, *, }; -use send_wrapper::SendWrapper; -use serde::{de::DeserializeOwned, Serialize}; +use serde::de::DeserializeOwned; use std::{error::Error, fmt::Debug, rc::Rc}; use thiserror::Error; use wasm_bindgen::{JsCast, JsValue, UnwrapThrowExt}; @@ -447,8 +440,7 @@ pub fn ActionForm( children: Children, ) -> impl IntoView where - ServFn: - Clone + DeserializeOwned + ServerFn + 'static, + ServFn: DeserializeOwned + ServerFn + 'static, <>::Request as ClientReq< ServFn::Error, >>::FormData: From, @@ -470,12 +462,10 @@ where }; let version = action.version(); let value = action.value(); - let input = action.input(); let class = class.map(|bx| bx.into_attribute_boxed()); let on_submit = { - let action_url = action_url.clone(); move |ev: SubmitEvent| { if ev.default_prevented() { return; diff --git a/router/src/components/router.rs b/router/src/components/router.rs index 1a8a77a8e4..dae95477c0 100644 --- a/router/src/components/router.rs +++ b/router/src/components/router.rs @@ -6,7 +6,7 @@ use crate::{ #[cfg(not(feature = "ssr"))] use crate::{unescape, Url}; use cfg_if::cfg_if; -use leptos::{server_fn::redirect::RedirectHook, *}; +use leptos::{logging::debug_warn, server_fn::redirect::RedirectHook, *}; #[cfg(feature = "transition")] use leptos_reactive::use_transition; use send_wrapper::SendWrapper; @@ -54,7 +54,9 @@ pub fn Router( } }); }) as RedirectHook; - server_fn::redirect::set_redirect_hook(router_hook); + if server_fn::redirect::set_redirect_hook(router_hook).is_err() { + debug_warn!("Error setting server function redirect hook."); + } children() }