This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// A middlware that filters a request body of type `application/x-www-form-urlencoded` | |
/// removing any key/value pairs having a zero-length value. | |
/// | |
/// This is a remediation for a design defect where the presence of any such null entries | |
/// will cause model decoding to fail. See https://github.com/vapor/vapor/issues/3046. | |
struct URLEncodedFormSanitizingMiddlware: AsyncMiddleware { | |
func respond(to request: Request, | |
chainingTo next: AsyncResponder) async throws -> Response { | |
// Read the entire body content, which might not yet be available. | |
let bodyString: String? |