tower-api-client 0.1.1

Toolkit for creating API clients with Tower
Documentation
use crate::utils::EmptyHello;
use tower::ServiceExt;
use tower_api_client::Client;
use wiremock::matchers::{method, path, query_param};
use wiremock::{Mock, MockServer, ResponseTemplate};

#[tokio::test]
async fn query_auth() {
    let _ = env_logger::try_init();
    let server = MockServer::start().await;
    let uri = server.uri();
    let auth = vec![("key", "k"), ("secret", "s")];
    let client = Client::new(&uri).query_auth(auth);

    Mock::given(method("GET"))
        .and(path("/hello"))
        .and(query_param("key", "k"))
        .and(query_param("secret", "s"))
        .respond_with(ResponseTemplate::new(200))
        .mount(&server)
        .await;

    client.oneshot(EmptyHello).await.unwrap();
}