mirror of
https://github.com/leptos-rs/leptos
synced 2024-11-10 06:44:17 +00:00
simplifying todo examples
This commit is contained in:
parent
fa8bb15a67
commit
068865b7de
3 changed files with 4 additions and 11 deletions
|
@ -29,8 +29,6 @@ pub async fn get_todos() -> Result<Vec<Todo>, ServerFnError> {
|
|||
// this is just an example of how to access server context injected in the handlers
|
||||
let req_parts = use_context::<leptos_actix::Request>();
|
||||
|
||||
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||
|
||||
if let Some(req_parts) = req_parts {
|
||||
println!("Path = {:?}", req_parts.path());
|
||||
}
|
||||
|
@ -60,7 +58,7 @@ pub async fn add_todo(title: String) -> Result<(), ServerFnError> {
|
|||
let mut conn = db().await?;
|
||||
|
||||
// fake API delay
|
||||
std::thread::sleep(std::time::Duration::from_millis(1250));
|
||||
std::thread::sleep(std::time::Duration::from_millis(250));
|
||||
|
||||
match sqlx::query("INSERT INTO todos (title, completed) VALUES ($1, false)")
|
||||
.bind(title)
|
||||
|
|
|
@ -20,11 +20,8 @@ pub async fn file_and_error_handler(
|
|||
if res.status() == StatusCode::OK {
|
||||
res.into_response()
|
||||
} else {
|
||||
let mut errors = Errors::default();
|
||||
errors.insert_with_default_key(TodoAppError::NotFound);
|
||||
let handler = leptos_axum::render_app_to_stream(
|
||||
move || view! { <ErrorTemplate outside_errors=errors.clone()/> },
|
||||
);
|
||||
let handler =
|
||||
leptos_axum::render_app_to_stream(move || shell(&options));
|
||||
handler(req).await.into_response()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,8 +31,6 @@ pub async fn get_todos() -> Result<Vec<Todo>, ServerFnError> {
|
|||
// this is just an example of how to access server context injected in the handlers
|
||||
let req_parts = use_context::<Parts>();
|
||||
|
||||
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
||||
|
||||
if let Some(req_parts) = req_parts {
|
||||
println!("Uri = {:?}", req_parts.uri);
|
||||
}
|
||||
|
@ -62,7 +60,7 @@ pub async fn add_todo(title: String) -> Result<(), ServerFnError> {
|
|||
let mut conn = db().await?;
|
||||
|
||||
// fake API delay
|
||||
std::thread::sleep(std::time::Duration::from_millis(1250));
|
||||
std::thread::sleep(std::time::Duration::from_millis(250));
|
||||
|
||||
match sqlx::query("INSERT INTO todos (title, completed) VALUES ($1, false)")
|
||||
.bind(title)
|
||||
|
|
Loading…
Reference in a new issue