Removed debug logs from the DocCMiddleware middleware in the library target.
This commit is contained in:
parent
f9e8088088
commit
8b3e9e47fd
@ -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
|
||||||
}
|
}
|
||||||
@ -51,8 +53,6 @@ struct DocCMiddleware<Context: RequestContext, AssetProvider: FileProvider>: Rou
|
|||||||
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)
|
||||||
}
|
}
|
||||||
@ -61,9 +61,6 @@ struct DocCMiddleware<Context: RequestContext, AssetProvider: FileProvider>: Rou
|
|||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user