Skip to content

Commit d30cdd4

Browse files
committed
Print the server's scheme when logging that it's reacahable
1 parent b30b5ed commit d30cdd4

5 files changed

Lines changed: 14 additions & 1 deletion

File tree

Sources/HummingbirdCore/Server/HTTP/HTTPChannelHandler.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public protocol HTTPChannelHandler: ServerChildChannel {
2525
var responder: Responder { get }
2626
}
2727

28+
extension HTTPChannelHandler {
29+
public var protocolScheme: String? { "http" }
30+
}
31+
2832
/// Internal error thrown when an unexpected HTTP part is received eg we didn't receive
2933
/// a head part when we expected one
3034
@usableFromInline

Sources/HummingbirdCore/Server/Server.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ public actor Server<ChildChannel: ServerChildChannel>: Service {
237237
logger: self.logger
238238
)
239239
}
240-
self.logger.info("Server started and listening on \(host):\(asyncChannel.channel.localAddress?.port ?? port)")
240+
let scheme = childChannelSetup.protocolScheme.map { $0 + "://" } ?? ""
241+
self.logger.info("Server started and listening on \(scheme)\(host):\(asyncChannel.channel.localAddress?.port ?? port)")
241242
return (asyncChannel, quiescingHelper)
242243

243244
case .unixDomainSocket(let path):

Sources/HummingbirdCore/Server/ServerChildChannel.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public protocol ServerChildChannelValue: Sendable {
2626
public protocol ServerChildChannel: Sendable {
2727
associatedtype Value: ServerChildChannelValue
2828

29+
var protocolScheme: String? { get }
30+
2931
/// Setup child channel
3032
/// - Parameters:
3133
/// - channel: Child channel
@@ -41,6 +43,8 @@ public protocol ServerChildChannel: Sendable {
4143
}
4244

4345
extension ServerChildChannel {
46+
public var protocolScheme: String? { nil }
47+
4448
/// Build existential ``Server`` from existential `ServerChildChannel`
4549
///
4650
/// - Parameters:

Sources/HummingbirdHTTP2/HTTP2Channel.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import NIOSSL
2525

2626
/// Child channel for processing HTTP1 with the option of upgrading to HTTP2
2727
public struct HTTP2UpgradeChannel: HTTPChannelHandler {
28+
public var protocolScheme: String? { "https" }
29+
2830
public struct Value: ServerChildChannelValue {
2931
let negotiatedHTTPVersion: EventLoopFuture<NIONegotiatedHTTPVersion<HTTP1Channel.Value, (NIOAsyncChannel<HTTP2Frame, HTTP2Frame>, NIOHTTP2Handler.AsyncStreamMultiplexer<HTTP1Channel.Value>)>>
3032
public let channel: Channel

Sources/HummingbirdTLS/TLSChannel.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public struct TLSChannel<BaseChannel: ServerChildChannel>: ServerChildChannel {
5858
}
5959

6060
extension TLSChannel: HTTPChannelHandler where BaseChannel: HTTPChannelHandler {
61+
public var protocolScheme: String? { "https" }
62+
6163
public var responder: HTTPChannelHandler.Responder {
6264
self.baseChannel.responder
6365
}

0 commit comments

Comments
 (0)