feat: Integrates view controller produced views, without working middleware protected routes. Need to get middleware working

This commit is contained in:
2025-01-24 09:50:55 -05:00
parent ce9cbe168e
commit aa60f69758
25 changed files with 53 additions and 2027 deletions

View File

@@ -9,22 +9,22 @@ extension Request {
headers.contains(name: "hx-request")
}
func render<C: HTML>(
@HTMLBuilder html: () async throws -> C
) async rethrows -> HTMLResponse where C: Sendable {
let html = try await html()
return HTMLResponse { html }
}
// Render the html if we're an htmx request, otherwise render the main page.
func render<C: HTML, D: SendableHTMLDocument>(
mainPage: (C) async throws -> D,
@HTMLBuilder html: () async throws -> C
) async rethrows -> HTMLResponse where C: Sendable {
let html = try await html()
guard isHtmxRequest else {
return try await render { try await mainPage(html) }
}
return HTMLResponse { html }
}
// func render<C: HTML>(
// @HTMLBuilder html: () async throws -> C
// ) async rethrows -> HTMLResponse where C: Sendable {
// let html = try await html()
// return HTMLResponse { html }
// }
//
// // Render the html if we're an htmx request, otherwise render the main page.
// func render<C: HTML, D: SendableHTMLDocument>(
// mainPage: (C) async throws -> D,
// @HTMLBuilder html: () async throws -> C
// ) async rethrows -> HTMLResponse where C: Sendable {
// let html = try await html()
// guard isHtmxRequest else {
// return try await render { try await mainPage(html) }
// }
// return HTMLResponse { html }
// }
}