feat: working on detail views.

This commit is contained in:
2025-01-12 17:42:06 -05:00
parent 0e31d2c30c
commit 1ce369e156
27 changed files with 527 additions and 137 deletions

View File

@@ -0,0 +1,22 @@
import Vapor
extension Request {
func ensureValidContent<T>(_ decoding: T.Type) throws -> T where T: Content, T: Validatable {
try T.validate(content: self)
return try content.decode(T.self)
}
func ensureIDPathComponent<T: LosslessStringConvertible>(
as decoding: T.Type = UUID.self,
key: String = "id"
) throws -> T {
guard let id = parameters.get(key, as: T.self) else {
throw Abort(.badRequest, reason: "Id not supplied.")
}
return id
}
var isHtmxRequest: Bool {
headers.contains(name: "hx-request")
}
}