1
0
mirror of https://github.com/fafhrd91/actix-net synced 2025-07-02 01:45:07 +02:00

convert Server::bind to accept a normal service factory

This commit is contained in:
Rob Ede
2021-10-25 18:03:52 +01:00
parent 81421c2ba9
commit 4c0eaca581
17 changed files with 277 additions and 128 deletions

View File

@ -50,13 +50,11 @@ async fn test_rustls_string() {
#[actix_rt::test]
async fn test_static_str() {
let srv = TestServer::with(|| {
fn_service(|io: TcpStream| async {
let mut framed = Framed::new(io, BytesCodec);
framed.send(Bytes::from_static(b"test")).await?;
Ok::<_, io::Error>(())
})
});
let srv = TestServer::with(fn_service(|io: TcpStream| async {
let mut framed = Framed::new(io, BytesCodec);
framed.send(Bytes::from_static(b"test")).await?;
Ok::<_, io::Error>(())
}));
let conn = actix_connect::default_connector();
@ -75,13 +73,11 @@ async fn test_static_str() {
#[actix_rt::test]
async fn test_new_service() {
let srv = TestServer::with(|| {
fn_service(|io: TcpStream| async {
let mut framed = Framed::new(io, BytesCodec);
framed.send(Bytes::from_static(b"test")).await?;
Ok::<_, io::Error>(())
})
});
let srv = TestServer::with(fn_service(|io: TcpStream| async {
let mut framed = Framed::new(io, BytesCodec);
framed.send(Bytes::from_static(b"test")).await?;
Ok::<_, io::Error>(())
}));
let factory = actix_connect::default_connector_factory();
@ -133,7 +129,7 @@ async fn test_rustls_uri() {
#[actix_rt::test]
async fn test_local_addr() {
let srv = TestServer::with(|| {
let srv = TestServer::with({
fn_service(|io: TcpStream| async {
let mut framed = Framed::new(io, BytesCodec);
framed.send(Bytes::from_static(b"test")).await?;

View File

@ -38,8 +38,9 @@ async fn custom_resolver() {
async fn custom_resolver_connect() {
use trust_dns_resolver::TokioAsyncResolver;
let srv =
TestServer::with(|| fn_service(|_io: TcpStream| async { Ok::<_, io::Error>(()) }));
let srv = TestServer::with(fn_service(|_io: TcpStream| async {
Ok::<_, io::Error>(())
}));
struct MyResolver {
trust_dns: TokioAsyncResolver,