mirror of
https://github.com/actix/examples
synced 2024-11-23 14:31:07 +01:00
refactor: switch from_fn to stable version
This commit is contained in:
parent
431ebe8c2b
commit
e962a2a9b1
@ -1,11 +1,10 @@
|
|||||||
use actix_web::{
|
use actix_web::{
|
||||||
body::{self, MessageBody},
|
body::{self, MessageBody},
|
||||||
dev::{self, ServiceResponse},
|
dev::{self, ServiceResponse},
|
||||||
middleware::Logger,
|
middleware::{from_fn, Logger, Next},
|
||||||
web::{self, Data, Json},
|
web::{self, Data, Json},
|
||||||
App, Error, HttpServer, Responder,
|
App, Error, HttpServer, Responder,
|
||||||
};
|
};
|
||||||
use actix_web_lab::middleware::{from_fn, Next};
|
|
||||||
use aes_gcm_siv::{aead::Aead as _, Aes256GcmSiv, KeyInit as _, Nonce};
|
use aes_gcm_siv::{aead::Aead as _, Aes256GcmSiv, KeyInit as _, Nonce};
|
||||||
use base64::prelude::*;
|
use base64::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
@ -33,4 +33,4 @@ A minimal middleware demonstrating the sequence of operations in an actix middle
|
|||||||
|
|
||||||
## See Also
|
## 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).
|
||||||
|
@ -1,16 +1,18 @@
|
|||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use actix_http::body::MessageBody;
|
use actix_web::{
|
||||||
use actix_web::{dev, rt::time, web, App, Error, HttpServer};
|
body::MessageBody,
|
||||||
use actix_web_lab::middleware::{from_fn, Next};
|
dev,
|
||||||
|
middleware::{from_fn, Next},
|
||||||
|
rt::time,
|
||||||
|
web, App, Error, HttpServer,
|
||||||
|
};
|
||||||
|
|
||||||
mod read_request_body;
|
mod read_request_body;
|
||||||
mod read_response_body;
|
mod read_response_body;
|
||||||
mod redirect;
|
mod redirect;
|
||||||
mod simple;
|
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(
|
async fn timeout_10secs(
|
||||||
req: dev::ServiceRequest,
|
req: dev::ServiceRequest,
|
||||||
next: Next<impl MessageBody + 'static>,
|
next: Next<impl MessageBody + 'static>,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use actix_web::{App, HttpServer};
|
use actix_web::{middleware::from_fn, App, HttpServer};
|
||||||
use actix_web_lab::{extract::ThinData, middleware::from_fn};
|
use actix_web_lab::extract::ThinData;
|
||||||
use tracing_actix_web::TracingLogger;
|
use tracing_actix_web::TracingLogger;
|
||||||
|
|
||||||
mod logging;
|
mod logging;
|
||||||
|
Loading…
Reference in New Issue
Block a user