diff --git a/README.md b/README.md index 4ab3346..a6dbf4a 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,23 @@ async fn test_simple_route_mock_async() { } ``` +Start a **stand-alone server** on a dedicated port: + +```rust +fn main() { + let opts = mockito::ServerOpts { + host: "0.0.0.0", + port: 1234, + ..Default::default() + }; + let mut server = mockito::Server::new_with_opts(opts); + + let _m = server.mock("GET", "/").with_body("hello world").create(); + + loop {} +} +``` + ## Minimum supported Rust toolchain The current minimum support Rust toolchain is **1.68.0** diff --git a/examples/mockito-server.rs b/examples/mockito-server.rs index 0dc5361..ce81cac 100644 --- a/examples/mockito-server.rs +++ b/examples/mockito-server.rs @@ -1,11 +1,14 @@ -use mockito; - use std::time::Duration; fn main() { - let mut s = mockito::Server::new(); + let opts = mockito::ServerOpts { + host: "0.0.0.0", + port: 1234, + ..Default::default() + }; + let mut server = mockito::Server::new_with_opts(opts); - s.mock("GET", "/").with_body("hello world"); + let _m = server.mock("GET", "/").with_body("hello world").create(); loop { std::thread::sleep(Duration::from_secs(1))