Skip to content

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

Initializers

Instance Methods

  • decode(_:from:)
    Decodes an instance of the supplied Decodable type from a String.
  • decode(_:from:headers:)
    Legacy “decode object” method. The provided NIOCore/ByteBuffer should be decoded as a value of the given type, optionally guided by the provided HTTPHeaders.
  • decode(_:from:headers:userInfo:)
    “Decode object” method. The provided NIOCore/ByteBuffer should be decoded as a value of the given type, optionally guided by the provided HTTPHeaders. The provided userInfo dictionary must be forwarded to the underlying Swift/Decoder used to perform the decoding operation.
  • decode(_:from:userInfo:)
    Decodes an instance of the supplied Decodable type from a String.

Relationships

Conforms To