Structure
URLEncodedFormDecoder
Decodes instances of
Decodable types from application/x-www-form-urlencoded data.struct URLEncodedFormDecoder
Overview
print(data) // "name=Vapor&age=3"
let user = try URLEncodedFormDecoder().decode(User.self, from: data)
print(user) // User
URL-encoded forms are commonly used by websites to send form data via POST requests. This encoding is relatively efficient for small amounts of data but must be percent-encoded. multipart/form-data is more efficient for sending larger data blobs like files, and application/json encoding has become increasingly common.
See the offical WhatWG URL standard for more information about the “URL-encoded WWW form” format.
Topics
Structures
struct ConfigurationEcapsulates configuration options for URL-encoded form decoding.
Initializers
Instance Methods
func decode(_:from:)Decodes an instance of the suppliedDecodabletype from aString.func decode<D>(D.Type, from: ByteBuffer, headers: HTTPHeaders) throws -> DLegacy “decode object” method. The providedNIOCore/ByteBuffershould be decoded as a value of the given type, optionally guided by the providedHTTPHeaders.func decode<D>(D.Type, from: ByteBuffer, headers: HTTPHeaders, userInfo: [CodingUserInfoKey : any Sendable]) throws -> D“Decode object” method. The providedNIOCore/ByteBuffershould be decoded as a value of the given type, optionally guided by the providedHTTPHeaders. The provideduserInfodictionary must be forwarded to the underlyingSwift/Decoderused to perform the decoding operation.func decode(_:from:userInfo:)Decodes an instance of the suppliedDecodabletype from aString.
Relationships
Conforms To
ContentDecoderSwift.SendableSwift.SendableMetatypeURLQueryDecoder