1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-07-01 16:55:08 +02:00

stop claiming actor support

This commit is contained in:
Rob Ede
2021-02-11 21:44:22 +00:00
parent ceace26ed4
commit 871ca5e4ae
4 changed files with 10 additions and 81 deletions

View File

@ -56,7 +56,6 @@
//! * SSL support using OpenSSL or Rustls
//! * 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.46+
//!
//! ## Crate Features
@ -203,29 +202,3 @@ pub mod dev {
}
}
}
pub mod client {
//! Actix Web async HTTP client.
//!
//! ```rust
//! use actix_web::client::Client;
//!
//! #[actix_web::main]
//! async fn main() {
//! let mut client = Client::default();
//!
//! // Create request builder and send request
//! let response = client.get("http://www.rust-lang.org")
//! .insert_header(("User-Agent", "actix-web/3.0"))
//! .send() // <- Send request
//! .await; // <- Wait for response
//!
//! println!("Response: {:?}", response);
//! }
//! ```
pub use awc::error::*;
pub use awc::{
test, Client, ClientBuilder, ClientRequest, ClientResponse, Connector,
};
}

View File

@ -1246,57 +1246,4 @@ mod tests {
let res = app.call(req).await.unwrap();
assert!(res.status().is_success());
}
#[actix_rt::test]
async fn test_actor() {
use crate::Error;
use actix::prelude::*;
struct MyActor;
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> {
let res = addr
.send(Num(1))
.await
.map_err(crate::error::ErrorInternalServerError)?;
if res == 1 {
Ok(HttpResponse::Ok())
} else {
Ok(HttpResponse::BadRequest())
}
}
let srv = App::new()
.data(addr.clone())
.service(web::resource("/").to(actor_handler));
let app = init_service(srv).await;
let req = TestRequest::post().uri("/").to_request();
let res = app.call(req).await.unwrap();
assert!(res.status().is_success());
}
}