This section describes matcher functions designed to target and match the TCP port in incoming HTTP requests.
These matchers are especially useful when using the proxy and record-and-playback features of httpmock.
port
Specifies the expected port number for incoming requests to match.
This constraint is especially useful when working with proxy or forwarding rules, but it
can also be used to serve mocks (e.g., when using a mock server as a proxy).
Parameters
port: A value convertible to u16, representing the expected port number.
Example
Errors
This function will panic if the port number cannot be converted to a valid u16 value.
Returns
The updated When instance to allow method chaining.
port_not
Specifies the port number that incoming requests must not match.
This constraint is especially useful when working with proxy or forwarding rules, but it
can also be used to serve mocks (e.g., when using a mock server as a proxy).
To add multiple excluded ports, invoke this function multiple times.
Parameters
port: A value convertible to u16, representing the port number to be excluded.
Example
Errors
This function will panic if the port number cannot be converted to a valid u16 value.
Returns
The updated When instance to enable method chaining.