Implemented the initialization functions for the DocCMiddleware type in the library target.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
// ===----------------------------------------------------------------------===
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// ===----------------------------------------------------------------------===
|
||||
|
||||
import Hummingbird
|
||||
|
||||
import class NIOPosix.NIOThreadPool
|
||||
import struct Logging.Logger
|
||||
|
||||
/// A middleware that proxies requests to `DocC` documentation containers within a hosting app.
|
||||
public struct DocCMiddleware {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// A protocol that defines file system interactions.
|
||||
let fileProvider: any FileProvider
|
||||
|
||||
/// A type that interacts with the logging system.
|
||||
let logger: Logger
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
/// Initializes this middleware with the root path to the `DocC` documentation containers in the file system.
|
||||
/// - Parameters:
|
||||
/// - pathToRoot: A path to the root folder in which the `DocC` documentation container are located.
|
||||
/// - logger: A type that interacts with the logging system.
|
||||
/// - threadPool: A representation of the thread pool that should be used in case some blocking work needs to be performed for which no non-blocking API exists.
|
||||
init(
|
||||
pathToRoot rootFolder: String,
|
||||
logger: Logger,
|
||||
threadPool: NIOThreadPool = .singleton
|
||||
) {
|
||||
self.fileProvider = LocalFileSystem(
|
||||
rootFolder: rootFolder,
|
||||
threadPool: threadPool,
|
||||
logger: logger
|
||||
)
|
||||
self.logger = logger
|
||||
}
|
||||
|
||||
/// Initializes this middleware with a type conforming to the `FileProvider` protocol.
|
||||
/// - Parameters:
|
||||
/// - fileProvider: A type that conforms to the protocol that defines file system interactions.
|
||||
/// - logger: A type that interacts with the logging system.
|
||||
init(
|
||||
fileProvider: any FileProvider,
|
||||
logger: Logger
|
||||
) {
|
||||
self.fileProvider = fileProvider
|
||||
self.logger = logger
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user