File tree Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Expand file tree Collapse file tree 1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change 170
170
//! JSON), any or missing. The following guide will walk you through the most common matchers. Check the
171
171
//! `Matcher` documentation for all the rest.
172
172
//!
173
- //! # Matching by path
173
+ //! # Matching by path and query
174
174
//!
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:
176
176
//!
177
177
//! ## Example
178
178
//!
179
179
//! ```
180
180
//! let mut s = mockito::Server::new();
181
181
//!
182
- //! // Matched only calls to GET /hello
182
+ //! // Matches only calls to GET /hello
183
183
//! s.mock("GET", "/hello").create();
184
+ //!
185
+ //! // Matches only calls to GET /hello?world=1
186
+ //! s.mock("GET", "/hello?world=1").create();
184
187
//! ```
185
188
//!
186
189
//! You can also match the path partially, by using a regular expression:
252
255
//! s.mock("GET", "/test?hello=world").create();
253
256
//! ```
254
257
//!
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
+ //!
255
269
//! # Matching by header
256
270
//!
257
271
//! By default, headers are compared by their exact value. The header name letter case is ignored though.
You can’t perform that action at this time.
0 commit comments