Array (ext)
You’re viewing third-party extensions to Array
, a struct from the Swift standard library.
You can also read the documentation forArray
itself.
extension Array
You’re viewing third-party extensions to Array
, a struct from the Swift standard library.
You can also read the documentation forArray
itself.
extension Array
@frozen struct Array<Element>
An ordered, random-access collection.
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.
protocol Content : Decodable, Encodable, AsyncRequestDecodable, AsyncResponseEncodable, RequestDecodable, ResponseEncodable
Convertible to / from content in an HTTP message.
protocol AsyncRequestDecodable
Can convert Request
to a Self
.
protocol AsyncResponseEncodable
Can convert self
to a Response
.
protocol RequestDecodable
Can convert Request
to a Self
.
protocol ResponseEncodable
Can convert self
to a Response
.
static var defaultContentType: HTTPMediaType { get }
static var defaultContentType: HTTPMediaType { get }
static func decodeRequest(_ request: Request) -> EventLoopFuture<Self>
static func decodeRequest(_ request: Request) async throws -> Self
mutating func afterDecode() throws
mutating func beforeEncode() throws
func encodeResponse(for request: Request) -> EventLoopFuture<Response>
func encodeResponse(for request: Request) async throws -> Response
func encodeResponse(status: HTTPStatus, headers: HTTPHeaders = [:], for request: Request) -> EventLoopFuture<Response>
Asynchronously encodes Self
into a Response
, setting the supplied status and headers.
func encodeResponse(status: HTTPStatus, headers: HTTPHeaders = [:], for request: Request) async throws -> Response
Asynchronously encodes Self
into a Response
, setting the supplied status and headers.
protocol FixedWidthInteger : BinaryInteger, LosslessStringConvertible where Self.Magnitude : FixedWidthInteger, Self.Magnitude : UnsignedInteger, Self.Stride : FixedWidthInteger, Self.Stride : SignedInteger
An integer type that uses a fixed size for every instance.
static func random(count: Int) -> [Element]
static func random<T>(count: Int, using generator: inout T) -> [Element] where T : RandomNumberGenerator
@preconcurrency protocol Middleware : Sendable
Middleware
is placed between the server and your router. It is capable of mutating both incoming requests and outgoing responses. Middleware
can choose to pass requests on to the next Middleware
in a chain, or they can short circuit and return a custom Response
if desired.
func makeResponder(chainingTo responder: Responder) -> Responder
Wraps a Responder
in an array of Middleware
creating a new Responder
.
struct HTTPMediaTypePreference
Represents a MediaType
and its associated preference, q
.
var mediaTypes: [HTTPMediaType] { get }
Returns all MediaType
s in this array of MediaTypePreference
.
func comparePreference(for a: HTTPMediaType, to b: HTTPMediaType) -> ComparisonResult
Returns ComparisonResult
comparing the supplied MediaType
s against these preferences.
@frozen struct UInt8
An 8-bit unsigned integer value type.
init?(decodingBase32 str: String)
Decode a string in canonical Base32-encoded representation.
init?<C>(decodingBase32 bytes: C) where C : RandomAccessCollection, C.Element == UInt8, C.Index == Int
init?(decodingBase64 str: String)
Decode a string in canonical Base32-encoded representation.
init?<C>(decodingBase64 bytes: C) where C : RandomAccessCollection, C.Element == UInt8, C.Index == Int
init?(decodingBcryptBase64 str: String)
Decode a string in Bcrypt-flavored Base64-encoded representation.
init?<C>(decodingBcryptBase64 bytes: C) where C : RandomAccessCollection, C.Element == UInt8, C.Index == Int
var base64: String { get }
protocol CodingKey : CustomDebugStringConvertible, CustomStringConvertible, Sendable
A type that can be used as a key for encoding and decoding.
var dotPath: String { get }