Content
Convertible to / from content in an HTTP message.
protocol Content : Decodable, Encodable, Sendable, AsyncRequestDecodable, AsyncResponseEncodable, RequestDecodable, ResponseEncodable
Browse conforming typesConformance to this protocol consists of:
Codable
RequestDecodable
ResponseEncodable
If adding conformance in an extension, you must ensure the type already conforms to Codable
.
struct Hello: Content {
let message = "Hello!"
}
router.get("greeting") { req in
return Hello() // {"message":"Hello!"}
}