mirror of
https://github.com/fafhrd91/actix-web
synced 2025-08-30 16:40:21 +02:00
bump actix dependency to v0.10 (#1666)
This commit is contained in:
@@ -59,7 +59,7 @@
|
||||
//! * Middlewares ([Logger, Session, CORS, etc](https://actix.rs/docs/middleware/))
|
||||
//! * Includes an async [HTTP client](https://actix.rs/actix-web/actix_web/client/index.html)
|
||||
//! * Supports [Actix actor framework](https://github.com/actix/actix)
|
||||
//! * Runs on stable Rust 1.41+
|
||||
//! * Runs on stable Rust 1.42+
|
||||
//!
|
||||
//! ## Crate Features
|
||||
//!
|
||||
|
93
src/test.rs
93
src/test.rs
@@ -1281,53 +1281,54 @@ mod tests {
|
||||
assert!(res.status().is_success());
|
||||
}
|
||||
|
||||
/*
|
||||
#[actix_rt::test]
|
||||
async fn test_actor() {
|
||||
use crate::Error;
|
||||
use actix::prelude::*;
|
||||
|
||||
Comment out until actix decoupled of actix-http:
|
||||
https://github.com/actix/actix/issues/321
|
||||
struct MyActor;
|
||||
|
||||
use futures::FutureExt;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn test_actor() {
|
||||
use actix::Actor;
|
||||
|
||||
struct MyActor;
|
||||
|
||||
struct Num(usize);
|
||||
impl actix::Message for Num {
|
||||
type Result = usize;
|
||||
}
|
||||
impl actix::Actor for MyActor {
|
||||
type Context = actix::Context<Self>;
|
||||
}
|
||||
impl actix::Handler<Num> for MyActor {
|
||||
type Result = usize;
|
||||
fn handle(&mut self, msg: Num, _: &mut Self::Context) -> Self::Result {
|
||||
msg.0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let mut app = init_service(App::new().service(web::resource("/index.html").to(
|
||||
move || {
|
||||
addr.send(Num(1)).map(|res| match res {
|
||||
Ok(res) => {
|
||||
if res == 1 {
|
||||
Ok(HttpResponse::Ok())
|
||||
} else {
|
||||
Ok(HttpResponse::BadRequest())
|
||||
}
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
})
|
||||
},
|
||||
)))
|
||||
.await;
|
||||
|
||||
let req = TestRequest::post().uri("/index.html").to_request();
|
||||
let res = app.call(req).await.unwrap();
|
||||
assert!(res.status().is_success());
|
||||
impl Actor for MyActor {
|
||||
type Context = Context<Self>;
|
||||
}
|
||||
*/
|
||||
|
||||
struct Num(usize);
|
||||
|
||||
impl Message for Num {
|
||||
type Result = usize;
|
||||
}
|
||||
|
||||
impl Handler<Num> for MyActor {
|
||||
type Result = usize;
|
||||
|
||||
fn handle(&mut self, msg: Num, _: &mut Self::Context) -> Self::Result {
|
||||
msg.0
|
||||
}
|
||||
}
|
||||
|
||||
let addr = MyActor.start();
|
||||
|
||||
async fn actor_handler(
|
||||
addr: Data<Addr<MyActor>>,
|
||||
) -> Result<impl Responder, Error> {
|
||||
// `?` operator tests "actors" feature flag on actix-http
|
||||
let res = addr.send(Num(1)).await?;
|
||||
|
||||
if res == 1 {
|
||||
Ok(HttpResponse::Ok())
|
||||
} else {
|
||||
Ok(HttpResponse::BadRequest())
|
||||
}
|
||||
}
|
||||
|
||||
let srv = App::new()
|
||||
.data(addr.clone())
|
||||
.service(web::resource("/").to(actor_handler));
|
||||
|
||||
let mut app = init_service(srv).await;
|
||||
|
||||
let req = TestRequest::post().uri("/").to_request();
|
||||
let res = app.call(req).await.unwrap();
|
||||
assert!(res.status().is_success());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user