Content

Convertible to / from content in an HTTP message.

Content.swift:21
protocol Content : Decodable, Encodable, Sendable, AsyncRequestDecodable, AsyncResponseEncodable, RequestDecodable, ResponseEncodable
Browse conforming types

Conformance 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!"}
}