Create an appropriate query-string parser.
| 15 | |
| 16 | // Create an appropriate query-string parser. |
| 17 | query_string_parser_type create_parser( int argc, char ** argv ) |
| 18 | { |
| 19 | if( argc < 2 || "restinio_defaults"s == argv[ 1 ] ) |
| 20 | return []( restinio::string_view_t what ) { |
| 21 | return restinio::try_parse_query< |
| 22 | restinio::parse_query_traits::restinio_defaults >( what ); |
| 23 | }; |
| 24 | |
| 25 | if( 2 == argc ) |
| 26 | { |
| 27 | if( "javascript_compatible"s == argv[ 1 ] ) |
| 28 | return []( restinio::string_view_t what ) { |
| 29 | return restinio::try_parse_query< |
| 30 | restinio::parse_query_traits::javascript_compatible >( what ); |
| 31 | }; |
| 32 | if( "x_www_form_urlencoded"s == argv[ 1 ] ) |
| 33 | return []( restinio::string_view_t what ) { |
| 34 | return restinio::try_parse_query< |
| 35 | restinio::parse_query_traits::x_www_form_urlencoded >( what ); |
| 36 | }; |
| 37 | if( "relaxed"s == argv[ 1 ] ) { |
| 38 | return []( restinio::string_view_t what ) { |
| 39 | return restinio::try_parse_query< |
| 40 | restinio::parse_query_traits::relaxed >( what ); |
| 41 | }; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | throw std::runtime_error{ |
| 46 | "one optional argument expected: " |
| 47 | "restinio_defaults, javascript_compatible, x_www_form_urlencoded or " |
| 48 | "relaxed" |
| 49 | }; |
| 50 | } |
| 51 | |
| 52 | // Create request handler. |
| 53 | restinio::request_handling_status_t handler( |