import Vapor extension Request { func ensureValidContent(_ decoding: T.Type) throws -> T where T: Content, T: Validatable { try T.validate(content: self) return try content.decode(T.self) } func ensureIDPathComponent( 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") } }