StubServer
public class StubServer
Defines the main Stub Server object. It can be subclassed to provide various other types of local server.
-
Current instance of any Local Server.
Declaration
Swift
public static var instance: LocalServerDelegate? { get set }
-
The default response for this server in case there is no given match for the response.
Declaration
Swift
public var defaultResponse: StubResponse
-
The default initializer for an empty StubServer
Declaration
Swift
public init()
-
Defines a route to this server. Multiple routes can be defined this way.
Declaration
Swift
public func route(_ methods: [HTTPMethod], url: String, handler: @escaping RouteHandler)
Parameters
methods
The set of HTTP Method that this route will be listening to.
url
The url string pattern attached to this route. It accept regex patterns.
handler
The route handler for this listener.
-
This function is called by the LocalServer everytime a new Request is fired by the URLSession mechanism.
Declaration
Swift
public func responseForURLRequest(_ urlRequest: URLRequest) -> StubResponse
Parameters
urlRequest
The incoming original URLRequest
Return Value
A StubResponse instance representing the stub response.