From e962a2a9b17bd329ffb2bd39d8eaeb0aec34704e Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Wed, 11 Sep 2024 10:31:11 -0400 Subject: [PATCH] refactor: switch from_fn to stable version --- middleware/encrypted-payloads/src/main.rs | 3 +-- middleware/various/README.md | 2 +- middleware/various/src/main.rs | 12 +++++++----- tracing/mainmatter-workshop/src/main.rs | 4 ++-- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/middleware/encrypted-payloads/src/main.rs b/middleware/encrypted-payloads/src/main.rs index da4d510..9d1d560 100644 --- a/middleware/encrypted-payloads/src/main.rs +++ b/middleware/encrypted-payloads/src/main.rs @@ -1,11 +1,10 @@ use actix_web::{ body::{self, MessageBody}, dev::{self, ServiceResponse}, - middleware::Logger, + middleware::{from_fn, Logger, Next}, web::{self, Data, Json}, App, Error, HttpServer, Responder, }; -use actix_web_lab::middleware::{from_fn, Next}; use aes_gcm_siv::{aead::Aead as _, Aes256GcmSiv, KeyInit as _, Nonce}; use base64::prelude::*; use serde::{Deserialize, Serialize}; diff --git a/middleware/various/README.md b/middleware/various/README.md index 0de435f..135f59a 100644 --- a/middleware/various/README.md +++ b/middleware/various/README.md @@ -33,4 +33,4 @@ A minimal middleware demonstrating the sequence of operations in an actix middle ## See Also -- The `from_fn` middleware constructor from [`actix-web-lab`](https://crates.io/crates/actix-web-lab). +- The [`from_fn` middleware constructor](https://docs.rs/actix-web/4/actix_web/middleware/fn.from_fn.html). diff --git a/middleware/various/src/main.rs b/middleware/various/src/main.rs index 31171bd..dccbeff 100644 --- a/middleware/various/src/main.rs +++ b/middleware/various/src/main.rs @@ -1,16 +1,18 @@ use std::time::Duration; -use actix_http::body::MessageBody; -use actix_web::{dev, rt::time, web, App, Error, HttpServer}; -use actix_web_lab::middleware::{from_fn, Next}; +use actix_web::{ + body::MessageBody, + dev, + middleware::{from_fn, Next}, + rt::time, + web, App, Error, HttpServer, +}; mod read_request_body; mod read_response_body; mod redirect; mod simple; -// See more examples of from_fn middleware here: -// https://github.com/robjtede/actix-web-lab/blob/main/actix-web-lab/examples/from_fn.rs async fn timeout_10secs( req: dev::ServiceRequest, next: Next, diff --git a/tracing/mainmatter-workshop/src/main.rs b/tracing/mainmatter-workshop/src/main.rs index ab5fdd2..8115b70 100644 --- a/tracing/mainmatter-workshop/src/main.rs +++ b/tracing/mainmatter-workshop/src/main.rs @@ -1,7 +1,7 @@ use std::io; -use actix_web::{App, HttpServer}; -use actix_web_lab::{extract::ThinData, middleware::from_fn}; +use actix_web::{middleware::from_fn, App, HttpServer}; +use actix_web_lab::extract::ThinData; use tracing_actix_web::TracingLogger; mod logging;