### Mock HTTP GET Request in Rust with httpmock Source: https://httpmock.rs/getting_started/quick_introduction This example demonstrates how to use the httpmock crate in Rust to mock an HTTP GET request. It sets up a mock server to respond to requests for the '/translate' path with a 'word=hello' query parameter, returning a 'hola' body. Requests not matching these criteria will receive a 404 Not Found response. ```rust use httpmock::prelude::*; #[test] fn translate_mock() { Mock::given(url("/translate")) .query_param("word", "hello") .respond_with(Response::new(200).body("hola")) .mount(); let client = reqwest::blocking::Client::new(); let response = client.get(Mock::url("/translate?word=hello")).send().unwrap(); assert_eq!(response.text().unwrap(), "hola"); } ``` -------------------------------- ### Add httpmock to Cargo.toml Source: https://httpmock.rs/getting_started/quick_introduction This snippet shows how to add the httpmock crate as a development dependency in your Rust project's Cargo.toml file. Ensure you are using the latest version available. ```toml [dev-dependencies] httpmock = "0.6.1" ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.