URLEncodedFormDecoder
Decodes instances of Decodable
types from application/x-www-form-urlencoded
data.
struct URLEncodedFormDecoder
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.