storage
Response.swift:75var storage: Storage { get set }
var storage: Storage { get set }
import Vapor
Vapor is a framework for building server applications, APIs and websites in Swift. It provides a safe, performant and scalable foundation for building large complex backends.
final class Response
An HTTP response from a server back to the client.
struct Storage
A container providing arbitrary storage for extensions of an existing type, designed to obviate the problem of being unable to add stored properties to a type in an extension. Each stored item is keyed by a type conforming to StorageKey
protocol.
convenience init(status: HTTPResponseStatus = .ok, version: HTTPVersion = .init(major: 1, minor: 1), headers: HTTPHeaders = .init(), body: Body = .empty)
Creates a new Response
.
init(status: HTTPResponseStatus, version: HTTPVersion, headersNoUpdate headers: HTTPHeaders, body: Body)
Internal init that creates a new Response
without sanitizing headers.
var body: Body { get set }
The Body
. Updating this property will also update the associated transport headers.
var content: ContentContainer { get set }
var cookies: HTTPCookies { get set }
Get and set HTTPCookies
for this Response
. This accesses the "Set-Cookie"
header.
var description: String { get }
See CustomStringConvertible
var headers: HTTPHeaders { get set }
The header fields for this HTTP response. The "Content-Length"
and "Transfer-Encoding"
headers will be set automatically when the body
property is mutated.
var status: HTTPResponseStatus { get set }
The HTTP response status.
var upgrader: Upgrader? { get set }
Optional Upgrade behavior to apply to this response. currently, websocket upgrades are the only defined case.
var version: HTTPVersion { get set }
The HTTP version that corresponds to this response.
func encodeResponse(for request: Request) -> EventLoopFuture<Response>
func encodeResponse(for request: Request) async throws -> Response
struct Body
Represents a Response
’s body.