2025-09-26 23:54:07 +00:00
|
|
|
// ===----------------------------------------------------------------------===
|
|
|
|
|
//
|
|
|
|
|
// This source file is part of the Hummingbird DocC Middleware open source project
|
|
|
|
|
//
|
|
|
|
|
// Copyright (c) 2025 Röck+Cöde VoF. and the Hummingbird DocC Middleware project authors
|
|
|
|
|
// Licensed under the EUPL 1.2 or later.
|
|
|
|
|
//
|
|
|
|
|
// See LICENSE for license information
|
|
|
|
|
// See CONTRIBUTORS for the list of Hummingbird DocC Middleware project authors
|
|
|
|
|
//
|
|
|
|
|
// ===----------------------------------------------------------------------===
|
|
|
|
|
|
2025-09-28 23:09:02 +02:00
|
|
|
import class Hummingbird.Router
|
2025-09-26 23:54:07 +00:00
|
|
|
|
2025-09-28 23:09:02 +02:00
|
|
|
import protocol Hummingbird.ApplicationProtocol
|
2025-09-26 23:54:07 +00:00
|
|
|
|
2025-09-28 23:09:02 +02:00
|
|
|
import struct Hummingbird.Application
|
|
|
|
|
import struct Hummingbird.BindAddress
|
2025-09-26 23:54:07 +00:00
|
|
|
import struct Logging.Logger
|
|
|
|
|
|
2025-09-28 23:09:02 +02:00
|
|
|
struct AppBuilder {
|
|
|
|
|
|
2025-09-26 23:54:07 +00:00
|
|
|
// MARK: Properties
|
|
|
|
|
|
2025-09-28 23:09:02 +02:00
|
|
|
/// A type that interacts with the logging system.
|
|
|
|
|
private let logger: Logger
|
2025-09-26 23:54:07 +00:00
|
|
|
|
|
|
|
|
// MARK: Initializers
|
|
|
|
|
|
2025-09-28 23:09:02 +02:00
|
|
|
/// Initializes this builder.
|
2025-09-26 23:54:07 +00:00
|
|
|
/// - Parameter logger: A type that interacts with the logging system.
|
|
|
|
|
init(logger: Logger) {
|
2025-09-28 23:09:02 +02:00
|
|
|
self.logger = logger
|
2025-09-26 23:54:07 +00:00
|
|
|
}
|
|
|
|
|
|
2025-09-28 23:09:02 +02:00
|
|
|
// MARK: Functions
|
2025-09-26 23:54:07 +00:00
|
|
|
|
2025-09-28 23:09:02 +02:00
|
|
|
func callAsFunction(
|
|
|
|
|
_ arguments: AppArguments
|
|
|
|
|
) -> some ApplicationProtocol {
|
|
|
|
|
let router = Router()
|
|
|
|
|
|
|
|
|
|
return Application(
|
|
|
|
|
router: router,
|
|
|
|
|
configuration: .init(
|
|
|
|
|
address: .hostname(arguments.hostname, port: arguments.port)
|
|
|
|
|
),
|
|
|
|
|
logger: logger
|
|
|
|
|
)
|
2025-09-26 23:54:07 +00:00
|
|
|
}
|
|
|
|
|
}
|