refactor: add unified gatherArgument helper for request parsing
This commit is contained in:
@@ -28,4 +28,11 @@ PIHTTP::MessageMutable noContent() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
PIString gatherArgument(const PIHTTP::MessageConst & request, const PIString & key) {
|
||||
PIJSON js = PIJSON::fromJSON(PIString::fromUTF8(request.body()));
|
||||
if (js.contains(key)) return js[key].toString();
|
||||
if (request.arguments().contains(key)) return request.arguments().value(key);
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace MessageUtils
|
||||
|
||||
Reference in New Issue
Block a user