HBHTTPServer

public final class HBHTTPServer

HTTP server class

  • EventLoopGroup used by server

    Declaration

    Swift

    public let eventLoopGroup: EventLoopGroup
  • Server configuration

    Declaration

    Swift

    public let configuration: Configuration
  • object initializing HTTP child handlers. This defaults to creating an HTTP1 channel

    Declaration

    Swift

    public var httpChannelInitializer: HBChannelInitializer
  • Server channel

    Declaration

    Swift

    public var channel: Channel?
  • HTTP server errors

    See more

    Declaration

    Swift

    public enum Error : Swift.Error
  • Initialize HTTP server

    Declaration

    Swift

    public init(group: EventLoopGroup, configuration: Configuration)

    Parameters

    group

    EventLoopGroup server uses

    configuration

    Configuration for server

  • Add TLS handler. Need to provide a closure so new instance of these handlers are created for each child channel

    Declaration

    Swift

    @discardableResult
    public func addTLSChannelHandler(_ handler: @autoclosure @escaping () -> RemovableChannelHandler) -> Self

    Parameters

    handler

    autoclosure generating handler

    position

    position to place channel handler

  • Append to list of ChannelHandlers to be added to server child channels. Need to provide a closure so new instance of these handlers are created for each child channel

    Declaration

    Swift

    @discardableResult
    public func addChannelHandler(_ handler: @autoclosure @escaping () -> RemovableChannelHandler) -> Self

    Parameters

    handler

    autoclosure generating handler

    position

    position to place channel handler

  • Start server

    Declaration

    Swift

    public func start(responder: HBHTTPResponder) -> EventLoopFuture<Void>

    Parameters

    responder

    Object that provides responses to requests sent to the server

    Return Value

    EventLoopFuture that is fulfilled when server has started

  • Stop HTTP server

    Declaration

    Swift

    public func stop() -> EventLoopFuture<Void>

    Return Value

    EventLoopFuture that is fulfilled when server has stopped

  • Wait on server. This won’t return until stop has been called

    Throws

    Error.serverNotRunning if server hasn’t fully started

    Declaration

    Swift

    public func wait() throws
  • Return array of child handlers added after HTTP handlers. Used by HBApplication.xct

    Declaration

    Swift

    public func getChildChannelHandlers(responder: HBHTTPResponder) -> [RemovableChannelHandler]

    Parameters

    responder

    final responder to user

  • Undocumented

    Declaration

    Swift

    public var port: Int? { get }
  • HTTP server configuration

    See more

    Declaration

    Swift

    public struct Configuration