Files
vapor-po/Sources/App/Controllers/UsersViewController.swift

37 lines
811 B
Swift

import Fluent
import Vapor
struct UserViewController: RouteCollection {
private let api = ApiController()
func boot(routes: any RoutesBuilder) throws {
let users = routes.protected.grouped("users")
users.get(use: index(req:))
}
@Sendable
func index(req: Request) async throws -> View {
let users = try await api.usersIndex(req: req)
return try await req.view.render("users", ["users": users])
}
}
struct UserFormCTX: Content {
let htmxTargetUrl: String
let htmxTarget: String
let htmxPushUrl: String
let showConfirmPassword: Bool
let buttonLabel: String
static func signIn(route: String) -> Self {
.init(
htmxTargetUrl: route,
htmxTarget: "body",
htmxPushUrl: "true",
showConfirmPassword: false,
buttonLabel: "Sign In"
)
}
}