From ca6eaee52e7a5c3f18b19a149060b93261fa5409 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Tue, 14 Mar 2023 02:40:02 +0000 Subject: [PATCH] update actix-web-lab dep --- Cargo.lock | 30 ++++++------------------------ Cargo.toml | 2 +- auth/cookie-auth/src/main.rs | 5 ++--- basics/todo/src/api.rs | 11 +++++------ https-tls/rustls/src/main.rs | 3 +-- templating/minijinja/src/main.rs | 4 ++-- 6 files changed, 17 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 651194a..45ed006 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -504,11 +504,10 @@ dependencies = [ [[package]] name = "actix-web-lab" -version = "0.18.9" +version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55b7ac6309cfb46949171c49f7bc81d021310205a39bf0b0d0465e80a4857e3c" +checksum = "9e9f49571dfcf49ed79c6e7a645e9554ae01925eb55fa6e3b2501ceeed24d7e7" dependencies = [ - "actix-files", "actix-http", "actix-router", "actix-service", @@ -534,7 +533,6 @@ dependencies = [ "pin-project-lite 0.2.9", "regex", "serde", - "serde_cbor_2", "serde_html_form", "serde_json", "tokio 1.26.0", @@ -543,9 +541,9 @@ dependencies = [ [[package]] name = "actix-web-lab-derive" -version = "0.18.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4419acd7924ac473ccd00a6efea324dd382b0b7ae31b8e06cd2c58d4d7afae6" +checksum = "16294584c7794939b1e5711f28e7cae84ef30e62a520db3f9af425f85269bcd2" dependencies = [ "proc-macro2", "quote", @@ -3386,12 +3384,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "half" -version = "1.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" - [[package]] name = "handlebars" version = "4.3.6" @@ -6324,16 +6316,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_cbor_2" -version = "0.12.0-dev" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b46d75f449e01f1eddbe9b00f432d616fbbd899b809c837d0fbc380496a0dd55" -dependencies = [ - "half", - "serde", -] - [[package]] name = "serde_derive" version = "1.0.155" @@ -6347,9 +6329,9 @@ dependencies = [ [[package]] name = "serde_html_form" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d051fb33111db0e81673ed8c55db741952a19ad81dc584960c8aec836498ba5" +checksum = "53192e38d5c88564b924dbe9b60865ecbb71b81d38c4e61c817cffd3e36ef696" dependencies = [ "form_urlencoded", "indexmap", diff --git a/Cargo.toml b/Cargo.toml index d4993b5..19cfee1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,7 +83,7 @@ actix-tls = "3" actix-utils = "3" actix-web = "4.3" actix-web-actors = "4.1" -actix-web-lab = "0.18" +actix-web-lab = "0.19" actix-ws = "0.2.5" awc = "3" diff --git a/auth/cookie-auth/src/main.rs b/auth/cookie-auth/src/main.rs index 83dda70..fc4fcf1 100644 --- a/auth/cookie-auth/src/main.rs +++ b/auth/cookie-auth/src/main.rs @@ -6,7 +6,6 @@ use actix_web::{ http::StatusCode, middleware, web, App, HttpMessage as _, HttpRequest, HttpServer, Responder, }; -use actix_web_lab::web::Redirect; const ONE_MINUTE: Duration = Duration::minutes(1); @@ -23,13 +22,13 @@ async fn index(identity: Option) -> actix_web::Result async fn login(req: HttpRequest) -> impl Responder { Identity::login(&req.extensions(), "user1".to_owned()).unwrap(); - Redirect::to("/").using_status_code(StatusCode::FOUND) + web::Redirect::to("/").using_status_code(StatusCode::FOUND) } async fn logout(id: Identity) -> impl Responder { id.logout(); - Redirect::to("/").using_status_code(StatusCode::FOUND) + web::Redirect::to("/").using_status_code(StatusCode::FOUND) } #[actix_web::main] diff --git a/basics/todo/src/api.rs b/basics/todo/src/api.rs index 00725ce..caaefd6 100644 --- a/basics/todo/src/api.rs +++ b/basics/todo/src/api.rs @@ -1,10 +1,9 @@ use actix_files::NamedFile; use actix_session::Session; -use actix_web::http::StatusCode; use actix_web::{ - dev, error, middleware::ErrorHandlerResponse, web, Error, HttpResponse, Responder, Result, + dev, error, http::StatusCode, middleware::ErrorHandlerResponse, web, Error, HttpResponse, + Responder, Result, }; -use actix_web_lab::web::Redirect; use serde::Deserialize; use sqlx::SqlitePool; use tera::{Context, Tera}; @@ -51,7 +50,7 @@ pub async fn create( ) -> Result { if params.description.is_empty() { session::set_flash(&session, FlashMessage::error("Description cannot be empty"))?; - Ok(Redirect::to("/").using_status_code(StatusCode::FOUND)) + Ok(web::Redirect::to("/").using_status_code(StatusCode::FOUND)) } else { db::create_task(params.into_inner().description, &pool) .await @@ -59,7 +58,7 @@ pub async fn create( session::set_flash(&session, FlashMessage::success("Task successfully added"))?; - Ok(Redirect::to("/").using_status_code(StatusCode::FOUND)) + Ok(web::Redirect::to("/").using_status_code(StatusCode::FOUND)) } } @@ -79,7 +78,7 @@ pub async fn update( form: web::Form, session: Session, ) -> Result { - Ok(Redirect::to(match form._method.as_ref() { + Ok(web::Redirect::to(match form._method.as_ref() { "put" => toggle(db, params).await?, "delete" => delete(db, params, session).await?, unsupported_method => { diff --git a/https-tls/rustls/src/main.rs b/https-tls/rustls/src/main.rs index 3e080a2..49d5857 100644 --- a/https-tls/rustls/src/main.rs +++ b/https-tls/rustls/src/main.rs @@ -4,7 +4,6 @@ use actix_files::Files; use actix_web::{ http::header::ContentType, middleware, web, App, HttpRequest, HttpResponse, HttpServer, }; -use actix_web_lab::web::redirect; use log::debug; use rustls::{Certificate, PrivateKey, ServerConfig}; use rustls_pemfile::{certs, pkcs8_private_keys}; @@ -34,7 +33,7 @@ async fn main() -> std::io::Result<()> { .wrap(middleware::Logger::default()) // register simple handler, handle all methods .service(web::resource("/index.html").to(index)) - .service(redirect("/", "/index.html")) + .service(web::redirect("/", "/index.html")) .service(Files::new("/static", "static")) }) .bind_rustls("127.0.0.1:8443", config)? diff --git a/templating/minijinja/src/main.rs b/templating/minijinja/src/main.rs index 1f35e69..1b2699d 100644 --- a/templating/minijinja/src/main.rs +++ b/templating/minijinja/src/main.rs @@ -1,7 +1,6 @@ -use actix_utils::future::{ready, Ready}; -use minijinja_autoreload::AutoReloader; use std::{collections::HashMap, env, path::PathBuf}; +use actix_utils::future::{ready, Ready}; use actix_web::{ dev::{self, ServiceResponse}, error, @@ -10,6 +9,7 @@ use actix_web::{ web, App, FromRequest, HttpRequest, HttpResponse, HttpServer, Responder, Result, }; use actix_web_lab::respond::Html; +use minijinja_autoreload::AutoReloader; struct MiniJinjaRenderer { tmpl_env: web::Data,