1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2025-09-01 08:52:45 +00:00

Refractor ApiClient and add support for body params

ApiClient was refractored to use PIMPL. This is mainly done to reduce
compile times whenever the implementation of ApiClient itself changes,
since a lot of files include it.

The loaders have gained support for body parameters, this was somehow
omitted before.
This commit is contained in:
Chris Josten 2021-09-03 03:47:25 +02:00
parent 1453cbbc63
commit 96ecd8e7d8
116 changed files with 4437 additions and 106 deletions

View file

@ -159,7 +159,19 @@ public:
this->m_reply->deleteLater();
}
this->m_isRunning = true;
m_reply = this->m_apiClient->get(path(this->m_parameters), query(this->m_parameters));
switch(operation()) {
case QNetworkAccessManager::GetOperation:
m_reply = this->m_apiClient->get(path(this->m_parameters), query(this->m_parameters));
break;
case QNetworkAccessManager::PostOperation:
m_reply = this->m_apiClient->post(path(this->m_parameters), body(this->m_parameters), query(this->m_parameters));
break;
default:
this->stopWithError(QStringLiteral("Unsupported network okperation %1").arg(operation()));
return;
}
this->connect(m_reply, &QNetworkReply::finished, this, &HttpLoader<R, P>::onRequestFinished);
}
@ -186,6 +198,8 @@ protected:
*/
virtual QString path(const P &parameters) const = 0;
virtual QUrlQuery query(const P &parameters) const = 0;
virtual QByteArray body(const P &parameters) const = 0;
virtual QNetworkAccessManager::Operation operation() const = 0;
private:
QNetworkReply *m_reply = nullptr;
QFutureWatcher<std::optional<R>> m_parsedWatcher;