Removed debug logs from the DocCMiddleware middleware in the library target.

This commit is contained in:
Javier Cicchelli 2025-02-26 00:59:26 +01:00
parent f9e8088088
commit 8b3e9e47fd

View File

@ -2,7 +2,10 @@ import Hummingbird
import Logging import Logging
import NIOPosix import NIOPosix
struct DocCMiddleware<Context: RequestContext, AssetProvider: FileProvider>: RouterMiddleware { struct DocCMiddleware<
Context: RequestContext,
AssetProvider: FileProvider
>: RouterMiddleware {
// MARK: Properties // MARK: Properties
@ -22,7 +25,6 @@ struct DocCMiddleware<Context: RequestContext, AssetProvider: FileProvider>: Rou
) )
} }
init(assetProvider: AssetProvider) { init(assetProvider: AssetProvider) {
self.assetProvider = assetProvider self.assetProvider = assetProvider
} }
@ -50,9 +52,7 @@ struct DocCMiddleware<Context: RequestContext, AssetProvider: FileProvider>: Rou
Redirect requests to / and /documentation to /documentation/ Redirect requests to / and /documentation to /documentation/
Redirect requests to /tutorials to /tutorials/ Redirect requests to /tutorials to /tutorials/
*/ */
print(uriPath)
guard uriPath.starts(with: /^\/archives\/\w+/) else { guard uriPath.starts(with: /^\/archives\/\w+/) else {
return try await next(input, context) return try await next(input, context)
} }
@ -60,10 +60,7 @@ struct DocCMiddleware<Context: RequestContext, AssetProvider: FileProvider>: Rou
let pathArchive = Path.archivePath(from: uriPath) let pathArchive = Path.archivePath(from: uriPath)
let nameArchive = Path.archiveName(from: uriPath) let nameArchive = Path.archiveName(from: uriPath)
let uriResource = Path.resourcePath(from: uriPath) let uriResource = Path.resourcePath(from: uriPath)
print(nameArchive)
print(uriResource)
if uriResource == .forwardSlash { if uriResource == .forwardSlash {
return .redirect(to: uriPath + "/documentation") return .redirect(to: uriPath + "/documentation")
} }
@ -125,16 +122,10 @@ private extension DocCMiddleware {
func serveFile( func serveFile(
_ path: String, _ path: String,
at folder: String? = nil, at folder: String,
context: Context context: Context
) async throws -> Response { ) async throws -> Response {
let filePath = if let folder { let filePath = folder + path
folder + path
} else {
path
}
print(filePath)
guard let fileIdentifier = assetProvider.getFileIdentifier(filePath) else { guard let fileIdentifier = assetProvider.getFileIdentifier(filePath) else {
throw HTTPError(.notFound) throw HTTPError(.notFound)
@ -142,9 +133,6 @@ private extension DocCMiddleware {
let body = try await assetProvider.loadFile(id: fileIdentifier, context: context) let body = try await assetProvider.loadFile(id: fileIdentifier, context: context)
print(fileIdentifier)
print(body)
return .init(status: .ok, headers: [:], body: body) return .init(status: .ok, headers: [:], body: body)
} }