Kitura

public class Kitura

A set of helper functions to make it easier to create, start, and stop Kitura based servers.

  • Add an HTTPServer on a port with a delegate.

    The server is only registered with the framework, it does not start listening on the port until Kitura.run() or Kitura.start() is called.

    Declaration

    Swift

    public class func addHTTPServer(onPort port: Int,
                                        with delegate: ServerDelegate,
                                        withSSL sslConfig: SSLConfig?=nil,
                                        keepAlive keepAliveState: KeepAliveState = .unlimited,
                                        allowPortReuse: Bool = false) -> HTTPServer

    Parameters

    onPort

    The port to listen on.

    with

    The ServerDelegate to use.

    withSSL

    The sslConfig to use.

    keepAlive

    The maximum number of additional requests to permit per Keep-Alive connection. Defaults to .unlimited. If set to .disabled, Keep-Alive will be not be permitted.

    allowPortReuse

    Determines whether the listener port may be shared with other Kitura instances (SO_REUSEPORT). Defaults to false. If the specified port is already in use by another listener that has not allowed sharing, the server will fail to start.

    Return Value

    The created HTTPServer.

  • Add a FastCGIServer on a port with a delegate.

    The server is only registered with the framework, it does not start listening on the port until Kitura.run() or Kitura.start() is called.

    Declaration

    Swift

    public class func addFastCGIServer(onPort port: Int,
                                           with delegate: ServerDelegate,
                                           allowPortReuse: Bool = false) -> FastCGIServer

    Parameters

    onPort

    The port to listen on.

    with

    The ServerDelegate to use.

    allowPortReuse

    Determines whether the listener port may be shared with other Kitura instances (SO_REUSEPORT). Defaults to false. If the specified port is already in use by another listener that has not allowed sharing, the server will fail to start.

    Return Value

    The created FastCGIServer.

  • Start the Kitura framework.

    Make all registered servers start listening on their port.

    Note

    This function never returns - it should be the last call in your main.swift

    Declaration

    Swift

    public class func run()
  • Start all registered servers and return

    Make all registered servers start listening on their port.

    Declaration

    Swift

    public class func start()
  • Stop all registered servers

    Make all registered servers stop listening on their port.

    Declaration

    Swift

    public class func stop(unregister: Bool = true)

    Parameters

    unregister

    If servers should be unregistered after stopped (default true).