NetworkMockOnRequestHandler
public struct NetworkMockOnRequestHandler
A handler for verifying outgoing requests.
-
Undocumented
Declaration
Swift
public typealias OnRequest<HTTPBody> = @Sendable (_ request: URLRequest, _ httpBody: HTTPBody?) -> Void
-
Creates a new request handler using the given
HTTPBody
type, which can be anyDecodable
.Declaration
Swift
public init<HTTPBody>(httpBodyType: HTTPBody.Type?, callback: @escaping OnRequest<HTTPBody>) where HTTPBody : Decodable
Parameters
httpBodyType
The decodable type to use for parsing the request body.
callback
The callback which will be called just before the request executes.
-
Creates a new request handler using the given callback to call on request without parsing the body arguments.
Declaration
Swift
public init(requestCallback: @escaping @Sendable (_ request: URLRequest) -> Void)
Parameters
requestCallback
The callback which will be executed just before the request executes, containing the request.
-
Creates a new request handler using the given callback to call on request without parsing the body arguments and without passing the request.
Declaration
Swift
public init(callback: @escaping @Sendable () -> Void)
Parameters
callback
The callback which will be executed just before the request executes.
-
Creates a new request handler using the given callback to call on request.
Declaration
Swift
public init(jsonDictionaryCallback: @escaping @Sendable (_ request: URLRequest, _ httpBodyArguments: [String : Any]?) -> Void)
Parameters
jsonDictionaryCallback
The callback that executes just before the request executes, containing the HTTP Body Arguments as a JSON Object Dictionary.
-
Creates a new request handler using the given callback to call on request.
Declaration
Swift
public init(jsonArrayCallback: @escaping @Sendable (_ request: URLRequest, _ httpBodyArguments: [[String : Any]]?) -> Void)
Parameters
jsonDictionaryCallback
The callback that executes just before the request executes, containing the HTTP Body Arguments as a JSON Object Array.