easyhttpmock-vetis-compio 0.1.0

EasyHttpMock adapter for Vetis HTTP server using compio runtime.
docs.rs failed to build easyhttpmock-vetis-compio-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

EasyHttpMock Vetis Compio

Crates.io downloads crates.io Build Status Crates.io MSRV Documentation MIT licensed codecov

This crate provides the core functionality for creating HTTP mock servers using the Compio runtime.

Quick Start

Add EasyHttpMock Vetis Compio to your Cargo.toml:

easyhttpmock-vetis-compio = { version = "0.1.0-beta.1", features = ["http2", "rust-tls"] }
compio = { version = "0.19.1", default-features = false, features = ["io-uring", "macros", "runtime"] }

Usage Example

Here's how simple it is to create a web server with VeTiS:

use easyhttpmock_vetis_compio::{
    EasyHttpMock,
    config::EasyHttpMockConfig,
    matchers::{method, path},
    mock::{AsyncMatcherExt, Mock, StatusCodeExt, given},
    vetis_adapter::VetisAdapter,
};
use http::{Method, StatusCode};
use std::error::Error;

#[compio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let config = EasyHttpMockConfig::<VetisAdapter>::default();
    let server = EasyHttpMock::new(config);
    let mut server = match server {
        Ok(server) => server,
        Err(err) => {
            panic!("Failed to create mock server: {}", err);
        }
    };

    let mock = Mock::of(
        given(method(Method::GET).and(path("/test"))).will_return(
            StatusCode::OK
                .respond()
                .with_body(b"teste"),
        ),
    );

    server.register_mock(mock).await?;

    Ok(())
}

License

Licensed under either of

at your option.

Author

Rogerio Pereira Araujo rogerio.araujo@gmail.com