Class
Request
Represents an HTTP request in an application.
final class Request
Topics
Structures
struct AuthenticationRequest helper for storing and fetching authenticated objects.struct Bodystruct Passwordstruct Services
Initializers
init(application: Application, method: HTTPMethod, url: URI, version: HTTPVersion, headers: HTTPHeaders, collectedBody: ByteBuffer?, remoteAddress: SocketAddress?, logger: Logger, byteBufferAllocator: ByteBufferAllocator, on: EventLoop)init(application: Application, method: HTTPMethod, url: URI, version: HTTPVersion, headers: HTTPHeaders, collectedBody: ByteBuffer?, remoteAddress: SocketAddress?, peerCertificateChain: ValidatedCertificateChain?, logger: Logger, byteBufferAllocator: ByteBufferAllocator, on: EventLoop)init(application: Application, method: HTTPMethod, url: URI, version: HTTPVersion, headersNoUpdate: HTTPHeaders, collectedBody: ByteBuffer?, remoteAddress: SocketAddress?, logger: Logger, byteBufferAllocator: ByteBufferAllocator, on: EventLoop)init(application: Application, method: HTTPMethod, url: URI, version: HTTPVersion, headersNoUpdate: HTTPHeaders, collectedBody: ByteBuffer?, remoteAddress: SocketAddress?, peerCertificateChain: ValidatedCertificateChain?, logger: Logger, byteBufferAllocator: ByteBufferAllocator, on: EventLoop)
Instance Properties
let application: Applicationvar auth: AuthenticationHelper for accessing authenticated objects. SeeAuthenticatorfor more information.var body: Bodyvar byteBufferAllocator: ByteBufferAllocatorvar cache: Cachevar client: Clientvar content: ContentContainerThis container is used to read yourDecodabletype using aContentDecoderimplementation. If noContentDecoderis provided, aRequest’sContent-Typeheader is used to select a registered decoder.var cookies: HTTPCookiesGet and setHTTPCookiesfor thisRequestThis accesses the"Cookie"header.var description: StringSeeCustomStringConvertiblelet eventLoop: EventLoopTheEventLoopwhich is handling thisRequest. The route handler and any relevant middleware are invoked in this event loop.var fileio: FileIOvar hasSession: Boolvar headers: HTTPHeadersThe header fields for this HTTP request. The"Content-Length"and"Transfer-Encoding"headers will be set automatically when thebodyproperty is mutated.let id: StringA unique ID for the request.var logger: LoggerThis Logger from Apple’sswift-logPackage is preferred when logging in the context of handing this Request. Vapor already provides metadata to this logger so that multiple logged messages can be traced back to the same request.var method: HTTPMethodThe HTTP method for this request.var parameters: ParametersA container containing the route parameters that were captured when receiving this request. Use this container to grab any non-static parameters from the URL, such as model IDs in a REST API.var password: Passwordvar peerAddress: SocketAddress?We try to determine true peer address if load balancer or reversed proxy provided info in headersvar peerCertificateChain: ValidatedCertificateChain?The validated certificate chain. This returns nil if the peer did not authenticate with a certificate. Requires configuring acustomCertificateVerifyCallbackWithMetadatathat performs the verification.var query: URLQueryContainerlet remoteAddress: SocketAddress?The address from which this HTTP request was received by SwiftNIO. This address may not represent the original address of the peer, especially if Vapor receives its requests through a reverse-proxy such as nginx.var route: Route?Route object we found for this request. This holds metadata that can be used for (for example) Metrics.var serviceContext: ServiceContextvar services: Servicesvar session: SessionReturns the currentSessionor creates one.var storage: StorageThis container is used as arbitrary request-local storage during the request-response lifecycle.Zvar url: URIThe URL used on this request.var version: HTTPVersionThe version for this HTTP request.var view: ViewRenderer
Instance Methods
func redirect(to: String, redirectType: Redirect) -> ResponseCreates a redirectResponse.func redirect(to: String, type: RedirectType) -> ResponseCreates a redirectResponse.func webSocket(maxFrameSize:shouldUpgrade:onUpgrade:)
Default Implementations
Relationships
Conforms To
AsyncRequestDecodableRequestDecodableSwift.CopyableSwift.CustomStringConvertibleSwift.EscapableSwift.SendableSwift.SendableMetatype