Renamed the DocCMiddleware.Configuration type in the library target as DocCConfiguration.
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
// ===----------------------------------------------------------------------===
|
||||||
|
//
|
||||||
|
// 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 class NIOPosix.NIOThreadPool
|
||||||
|
|
||||||
|
/// A type that contains all the parameters to configure the ``DocCMiddleware`` middleware.
|
||||||
|
public struct DocCConfiguration: Sendable {
|
||||||
|
|
||||||
|
// MARK: Properties
|
||||||
|
|
||||||
|
/// A path to the physical location where the `DocC` documentation containers are stored.
|
||||||
|
let folderRoot: String
|
||||||
|
|
||||||
|
/// A URI path that prefixes the `DocC` documentation resources.
|
||||||
|
let uriRoot: String
|
||||||
|
|
||||||
|
/// A type that define a mechanism to use in case some blocking work needs to be performed for which no non-blocking API exists.
|
||||||
|
let threadPool: NIOThreadPool
|
||||||
|
|
||||||
|
// MARK: Initializers
|
||||||
|
|
||||||
|
/// Initializes this configuration type.
|
||||||
|
///
|
||||||
|
/// > important: It is assumed that both the `uriRoot` and the `folderRoot` parameters should not be empty, and that they should be prefixed
|
||||||
|
/// with the `/` forward slash character.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - uriRoot: A URI path that prefixes the `DocC` documentation resources.
|
||||||
|
/// - folderRoot: A path to the physical location where the `DocC` documentation containers are stored.
|
||||||
|
/// - threadPool: A type that define a mechanism to use in case some blocking work needs to be performed for which no non-blocking API exists.
|
||||||
|
public init(
|
||||||
|
uriRoot: String,
|
||||||
|
folderRoot: String,
|
||||||
|
threadPool: NIOThreadPool = .singleton
|
||||||
|
) {
|
||||||
|
self.folderRoot = folderRoot
|
||||||
|
self.uriRoot = uriRoot
|
||||||
|
self.threadPool = threadPool
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
// ===----------------------------------------------------------------------===
|
|
||||||
//
|
|
||||||
// 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 class NIOPosix.NIOThreadPool
|
|
||||||
|
|
||||||
extension DocCMiddleware {
|
|
||||||
/// A type that contains all the parameters to configure the ``DocCMiddleware`` middleware.
|
|
||||||
public struct Configuration: Sendable {
|
|
||||||
|
|
||||||
// MARK: Properties
|
|
||||||
|
|
||||||
/// A path to the physical location where the `DocC` documentation containers are stored.
|
|
||||||
let folderRoot: String
|
|
||||||
|
|
||||||
/// A URI path that prefixes the `DocC` documentation resources.
|
|
||||||
let uriRoot: String
|
|
||||||
|
|
||||||
/// A type that define a mechanism to use in case some blocking work needs to be performed for which no non-blocking API exists.
|
|
||||||
let threadPool: NIOThreadPool
|
|
||||||
|
|
||||||
// MARK: Initializers
|
|
||||||
|
|
||||||
/// Initializes this configuration type.
|
|
||||||
///
|
|
||||||
/// > important: It is assumed that both the `uriRoot` and the `folderRoot` parameters should not be empty, and that they should be prefixed
|
|
||||||
/// with the `/` forward slash character.
|
|
||||||
///
|
|
||||||
/// - Parameters:
|
|
||||||
/// - uriRoot: A URI path that prefixes the `DocC` documentation resources.
|
|
||||||
/// - folderRoot: A path to the physical location where the `DocC` documentation containers are stored.
|
|
||||||
/// - threadPool: A type that define a mechanism to use in case some blocking work needs to be performed for which no non-blocking API exists.
|
|
||||||
public init(
|
|
||||||
uriRoot: String,
|
|
||||||
folderRoot: String,
|
|
||||||
threadPool: NIOThreadPool = .singleton
|
|
||||||
) {
|
|
||||||
self.folderRoot = folderRoot
|
|
||||||
self.uriRoot = uriRoot
|
|
||||||
self.threadPool = threadPool
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -46,9 +46,6 @@ public struct DocCMiddleware<FileSystemProvider: FileProvider> {
|
|||||||
|
|
||||||
// MARK: Properties
|
// MARK: Properties
|
||||||
|
|
||||||
/// A type that contains the parameters to configure the middleware.
|
|
||||||
let configuration: Configuration
|
|
||||||
|
|
||||||
/// A type that conforms to a protocol that defines file system interactions.
|
/// A type that conforms to a protocol that defines file system interactions.
|
||||||
let fileProvider: FileSystemProvider
|
let fileProvider: FileSystemProvider
|
||||||
|
|
||||||
@@ -74,7 +71,7 @@ public struct DocCMiddleware<FileSystemProvider: FileProvider> {
|
|||||||
/// - configuration: A type that contains the parameters to configure the middleware.
|
/// - configuration: A type that contains the parameters to configure the middleware.
|
||||||
/// - logger: A type that interacts with the logging system.
|
/// - logger: A type that interacts with the logging system.
|
||||||
public init(
|
public init(
|
||||||
configuration: Configuration,
|
configuration: DocCConfiguration,
|
||||||
logger: Logger
|
logger: Logger
|
||||||
) where FileSystemProvider == LocalFileSystem {
|
) where FileSystemProvider == LocalFileSystem {
|
||||||
self.init(
|
self.init(
|
||||||
@@ -94,12 +91,11 @@ public struct DocCMiddleware<FileSystemProvider: FileProvider> {
|
|||||||
/// - fileProvider: A type that conforms to the protocol that defines file system interactions.
|
/// - fileProvider: A type that conforms to the protocol that defines file system interactions.
|
||||||
/// - logger: A type that interacts with the logging system.
|
/// - logger: A type that interacts with the logging system.
|
||||||
init(
|
init(
|
||||||
configuration: Configuration,
|
configuration: DocCConfiguration,
|
||||||
fileProvider: FileSystemProvider,
|
fileProvider: FileSystemProvider,
|
||||||
logger: Logger,
|
logger: Logger,
|
||||||
) {
|
) {
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
self.configuration = configuration
|
|
||||||
self.fileProvider = fileProvider
|
self.fileProvider = fileProvider
|
||||||
self.prepareURIPath = .init(uriRoot: configuration.uriRoot)
|
self.prepareURIPath = .init(uriRoot: configuration.uriRoot)
|
||||||
self.redirectURI = .init(logger: logger)
|
self.redirectURI = .init(logger: logger)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import struct Hummingbird.LocalFileSystem
|
|||||||
import struct Hummingbird.Request
|
import struct Hummingbird.Request
|
||||||
import struct Logging.Logger
|
import struct Logging.Logger
|
||||||
|
|
||||||
|
@testable import struct HummingbirdDocC.DocCConfiguration
|
||||||
@testable import struct HummingbirdDocC.DocCMiddleware
|
@testable import struct HummingbirdDocC.DocCMiddleware
|
||||||
|
|
||||||
@Suite("DocC Middleware", .tags(.middleware))
|
@Suite("DocC Middleware", .tags(.middleware))
|
||||||
@@ -290,7 +291,7 @@ private extension DocCMiddlewareTests {
|
|||||||
/// - configuration: A type that contains the parameters to configure the middleware.
|
/// - configuration: A type that contains the parameters to configure the middleware.
|
||||||
/// - logger: A type that interacts with the logging system.
|
/// - logger: A type that interacts with the logging system.
|
||||||
func assertInit(
|
func assertInit(
|
||||||
configuration: DocCMiddleware<LocalFileSystem>.Configuration,
|
configuration: DocCConfiguration,
|
||||||
logger: Logger = .test()
|
logger: Logger = .test()
|
||||||
) {
|
) {
|
||||||
// GIVEN
|
// GIVEN
|
||||||
@@ -318,7 +319,7 @@ private extension DocCMiddlewareTests {
|
|||||||
/// - logger: A type that interacts with the logging system.
|
/// - logger: A type that interacts with the logging system.
|
||||||
/// - fileProvider: A type that conforms to the protocol that defines file system interactions, if any.
|
/// - fileProvider: A type that conforms to the protocol that defines file system interactions, if any.
|
||||||
func assertInit<FileSystemProvider: FileProvider>(
|
func assertInit<FileSystemProvider: FileProvider>(
|
||||||
configuration: DocCMiddleware<FileSystemProvider>.Configuration,
|
configuration: DocCConfiguration,
|
||||||
logger: Logger = .test(),
|
logger: Logger = .test(),
|
||||||
fileProvider: FileSystemProvider
|
fileProvider: FileSystemProvider
|
||||||
) {
|
) {
|
||||||
@@ -448,7 +449,7 @@ private extension DocCMiddlewareTests {
|
|||||||
default: .init(fileIdentifier: .init(), shouldLoadFile: false)
|
default: .init(fileIdentifier: .init(), shouldLoadFile: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
let context: any RequestContext = RequestContextMock(logger: logger)
|
let context: RequestContextMock = .init(logger: logger)
|
||||||
let request: Request = .test(
|
let request: Request = .test(
|
||||||
method: .get,
|
method: .get,
|
||||||
path: uriPath
|
path: uriPath
|
||||||
@@ -475,7 +476,7 @@ private extension DocCMiddlewareTests {
|
|||||||
.contentLength: (statusCode == .ok ? "36" : "0")
|
.contentLength: (statusCode == .ok ? "36" : "0")
|
||||||
])
|
])
|
||||||
|
|
||||||
let contentLength = try #require(result.body.contentLength)
|
let contentLength = #require(result.body.contentLength)
|
||||||
|
|
||||||
if statusCode == .ok {
|
if statusCode == .ok {
|
||||||
#expect(contentLength > 0)
|
#expect(contentLength > 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user