Created
April 2, 2012 10:53
-
-
Save Aqua-Ye/2282558 to your computer and use it in GitHub Desktop.
HttpRequest.get_form_data for Opa
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
function get_form_data() { | |
function decode(s) { String.replace("+", " ", Uri.decode_string(s)) } | |
match (HttpRequest.get_body()) { | |
case {none}: StringMap.empty | |
case {some:body}: | |
match (Parser.try_parse(UriParser.query_parser, body)) { | |
case {none}: StringMap.empty | |
case {some:list}: | |
List.fold(function((a, b), acc) { | |
StringMap.add(decode(a), decode(b), acc) | |
}, list, StringMap.empty) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
An example of usage :