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