Skip to content

Commit c7db8f0

Browse files
committed
wip: page not found should return status notFound
1 parent 6bf7c59 commit c7db8f0

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Sources/App/Middlewares/SiteMiddleware.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ private struct NotFoundMiddleware<Context: RequestContext>: RouterMiddleware {
7575
guard error.status == .notFound else {
7676
throw error
7777
}
78+
7879
return try NotFoundPage()
79-
.response(from: input, context: context)
80+
.response(from: input, context: context, status: .notFound)
8081
}
8182
}
8283
}

Sources/Pages/Utils/Page+ResponseGenerator.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@ extension Page {
66
public consuming func response(
77
from request: Request,
88
context: some RequestContext
9+
) throws -> Response {
10+
try self.response(from: request, context: context, status: .ok)
11+
}
12+
13+
public consuming func response(
14+
from request: Request,
15+
context: some RequestContext,
16+
status: HTTPResponse.Status
917
) throws -> Response {
1018
Response(
11-
status: .ok,
19+
status: status,
1220
headers: self.headers,
1321
body: ResponseBody { [self] writer in
1422
try await writer.write(self, chunkSize: self.chunkSize)

0 commit comments

Comments
 (0)