BodyParserMultiValue
public class BodyParserMultiValue : BodyParser
The BodyParserMultiValue
is a subclass of BodyParser
, which differs in behaviour
when decoding urlencoded parameters with multiple values (such as &a=1&a=2
).
Whereas BodyParser
will produce a comma-separated list of values: ["a": "1,2"]
which may be accessed by ParsedBody.urlEncoded
, BodyParserMultiValue
will
produce an array of values: ["a": ["1", "2"]]
, accessed by ParsedBody.urlEncodedMultiValue
.
This enables you to accept multiple values which may themselves contain commas.
-
This function is called by the Kitura
Router
when an incoming request matches the route provided when the BodyParser was registered with theRouter
. It performs the parsing of the body content usingparse(_:contentType)
. We don’t expect a user to call this function directly.Declaration
Swift
override public func handle(request: RouterRequest, response: RouterResponse, next: @escaping () -> Void) throws
Parameters
request
The
RouterRequest
object used to work with the incoming HTTP request.response
The
RouterResponse
object used to respond to the HTTP request.next
The closure called to invoke the next handler or middleware associated with the request.