Skip to content

Commit 1276b06

Browse files
committed
Update docs on the path matcher
1 parent 6b7621e commit 1276b06

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/lib.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,20 @@
170170
//! JSON), any or missing. The following guide will walk you through the most common matchers. Check the
171171
//! `Matcher` documentation for all the rest.
172172
//!
173-
//! # Matching by path
173+
//! # Matching by path and query
174174
//!
175-
//! By default, the request path is compared by its exact value:
175+
//! By default, the request path and query is compared by its exact value:
176176
//!
177177
//! ## Example
178178
//!
179179
//! ```
180180
//! let mut s = mockito::Server::new();
181181
//!
182-
//! // Matched only calls to GET /hello
182+
//! // Matches only calls to GET /hello
183183
//! s.mock("GET", "/hello").create();
184+
//!
185+
//! // Matches only calls to GET /hello?world=1
186+
//! s.mock("GET", "/hello?world=1").create();
184187
//! ```
185188
//!
186189
//! You can also match the path partially, by using a regular expression:
@@ -252,6 +255,17 @@
252255
//! s.mock("GET", "/test?hello=world").create();
253256
//! ```
254257
//!
258+
//! If you'd like to ignore the query entirely, use the `Matcher::Any` variant:
259+
//!
260+
//! ## Example
261+
//!
262+
//! ```
263+
//! let mut s = mockito::Server::new();
264+
//!
265+
//! // This will match requests to GET /test with any query
266+
//! s.mock("GET", "/test").match_query(mockito::Matcher::Any).create();
267+
//! ```
268+
//!
255269
//! # Matching by header
256270
//!
257271
//! By default, headers are compared by their exact value. The header name letter case is ignored though.

0 commit comments

Comments
 (0)