| 128 | } |
| 129 | |
| 130 | RESTResponseFormat ParseDataFormat(std::string& param, const std::string& strReq) |
| 131 | { |
| 132 | // Remove query string (if any, separated with '?') as it should not interfere with |
| 133 | // parsing param and data format |
| 134 | param = strReq.substr(0, strReq.rfind('?')); |
| 135 | const std::string::size_type pos_format{param.rfind('.')}; |
| 136 | |
| 137 | // No format string is found |
| 138 | if (pos_format == std::string::npos) { |
| 139 | return RESTResponseFormat::UNDEF; |
| 140 | } |
| 141 | |
| 142 | // Match format string to available formats |
| 143 | const std::string suffix(param, pos_format + 1); |
| 144 | for (const auto& rf_name : rf_names) { |
| 145 | if (suffix == rf_name.name) { |
| 146 | param.erase(pos_format); |
| 147 | return rf_name.rf; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | // If no suffix is found, return RESTResponseFormat::UNDEF and original string without query string |
| 152 | return RESTResponseFormat::UNDEF; |
| 153 | } |
| 154 | |
| 155 | static std::string AvailableDataFormatsString() |
| 156 | { |