HTTPServer
public class HTTPServer: HTTPServing
A basic HTTP server. Currently this is implemented using the PoCSocket abstraction, but the intention is to remove this dependency and reimplement the class using transport APIs provided by the Server APIs working group.
-
Create an instance of the server. This needs to be followed with a call to
start(port:handler:)
Declaration
Swift
public init()
-
Start the HTTP server on the given
port
number, using aHTTPRequestHandler
to process incoming requests.Declaration
Swift
public func start(port: Int = 0, handler: @escaping HTTPRequestHandler) throws
-
Stop the server
Declaration
Swift
public func stop()
-
The port number the server is listening on
Declaration
Swift
public var port: Int
-
The number of current connections
Declaration
Swift
public var connectionCount: Int