Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
feat: add route for Url encoded forms #1228
update the codable router's POST handlers to detect application/x-www-form-urlencoded using the query parameters decoding logic. This allows users to send a html form to a Kitura router which will decode to a codable struct.
How Has This Been Tested?
A new test has been added for this behaviour and this along with all other Kitura tests pass.
This was also tested manually by setting up a html form, a Kitura route and a codable struct. The form successfully sent a post request to the router which was mapped to the codable struct.
Since this is changing an existing route it will probably be worth testing the performance impact.
@@ Coverage Diff @@ ## master #1228 +/- ## ========================================== + Coverage 89.39% 89.62% +0.23% ========================================== Files 38 38 Lines 2234 2246 +12 ========================================== + Hits 1997 2013 +16 + Misses 237 233 -4
This looks good, however it will have some performance impact. We'd need to run a comparison to determine how much. In particular I'd be concerned with increasing overhead if we were to support more
Content-Types in the future.
I've suggested an approach that might help avoid this (by only parsing the
Content-Type once per request object).
FWIW, there was no measurable performance penalty for a simple benchmark using Codable routing:
This looks good. I'll add a FIXME for the future improvement to querying Request's content type.