Method
This section describes matcher functions designed to target and match the method in incoming HTTP requests,
such as GET
, POST
, etc.
method
Sets the expected HTTP method for which the mock server should respond.
This method ensures that the mock server only matches requests that use the specified HTTP method,
such as GET
, POST
, or any other valid method. This allows testing behavior that’s specific
to different types of HTTP requests.
Note: Method matching is case-insensitive.
Example
Parameters
method
: An HTTP method as either aMethod
enum or aString
value, specifying the expected method type for matching.
Returns
The updated When
instance to allow for method chaining.
method_not
Excludes the specified HTTP method from the requests the mock server will respond to.
This method ensures that the mock server does not respond to requests using the given HTTP method,
like GET
, POST
, etc. This allows testing scenarios where a particular method should not
trigger a response, and thus testing behaviors like method-based security.
Note: Method matching is case-insensitive.
Example
Parameters
method
: An HTTP method as either aMethod
enum or aString
value, specifying the method type to exclude from matching.
Returns
The updated When
instance to allow for method chaining.