mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 21:12:53 +02:00
Add HTTP route to get metaverse info.
This commit is contained in:
parent
e6f3ba4458
commit
7a033f93da
1 changed files with 17 additions and 2 deletions
|
@ -118,7 +118,7 @@ bool DomainServer::forwardMetaverseAPIRequest(HTTPConnection* connection,
|
||||||
root.insert(requestSubobjectKey, subobject);
|
root.insert(requestSubobjectKey, subobject);
|
||||||
QJsonDocument doc { root };
|
QJsonDocument doc { root };
|
||||||
|
|
||||||
QUrl url{ MetaverseAPI::getCurrentMetaverseServerURL().toString() + metaversePath };
|
QUrl url { MetaverseAPI::getCurrentMetaverseServerURL().toString() + metaversePath };
|
||||||
|
|
||||||
QNetworkRequest req(url);
|
QNetworkRequest req(url);
|
||||||
req.setHeader(QNetworkRequest::UserAgentHeader, NetworkingConstants::VIRCADIA_USER_AGENT);
|
req.setHeader(QNetworkRequest::UserAgentHeader, NetworkingConstants::VIRCADIA_USER_AGENT);
|
||||||
|
@ -1979,6 +1979,8 @@ const QString URI_OAUTH = "/oauth";
|
||||||
bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) {
|
bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) {
|
||||||
const QString JSON_MIME_TYPE = "application/json";
|
const QString JSON_MIME_TYPE = "application/json";
|
||||||
|
|
||||||
|
const QString URI_DOMAIN_METAVERSE_INFO = "/domain/metaverse_info";
|
||||||
|
const QString URI_ID = "/id";
|
||||||
const QString URI_ASSIGNMENT = "/assignment";
|
const QString URI_ASSIGNMENT = "/assignment";
|
||||||
const QString URI_NODES = "/nodes";
|
const QString URI_NODES = "/nodes";
|
||||||
const QString URI_SETTINGS = "/settings";
|
const QString URI_SETTINGS = "/settings";
|
||||||
|
@ -2055,7 +2057,6 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if this is a request for our domain ID
|
// check if this is a request for our domain ID
|
||||||
const QString URI_ID = "/id";
|
|
||||||
if (connection->requestOperation() == QNetworkAccessManager::GetOperation
|
if (connection->requestOperation() == QNetworkAccessManager::GetOperation
|
||||||
&& url.path() == URI_ID) {
|
&& url.path() == URI_ID) {
|
||||||
QUuid domainID = nodeList->getSessionUUID();
|
QUuid domainID = nodeList->getSessionUUID();
|
||||||
|
@ -2063,6 +2064,20 @@ bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url
|
||||||
connection->respond(HTTPConnection::StatusCode200, uuidStringWithoutCurlyBraces(domainID).toLocal8Bit());
|
connection->respond(HTTPConnection::StatusCode200, uuidStringWithoutCurlyBraces(domainID).toLocal8Bit());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if this is a request for our selected metaverse server info
|
||||||
|
if (connection->requestOperation() == QNetworkAccessManager::GetOperation
|
||||||
|
&& url.path() == URI_DOMAIN_METAVERSE_INFO) {
|
||||||
|
const QString MIME_TYPE = "application/json";
|
||||||
|
|
||||||
|
QString metaverseURL{ MetaverseAPI::getCurrentMetaverseServerURL().toString() };
|
||||||
|
QJsonObject jsonObject{ { "metaverse_url", metaverseURL } };
|
||||||
|
QString domainMetaverseInfoJSON =
|
||||||
|
QString("{\"metaverse\":%1}").arg(QString(QJsonDocument(jsonObject).toJson(QJsonDocument::Compact)));
|
||||||
|
|
||||||
|
connection->respond(HTTPConnection::StatusCode200, domainMetaverseInfoJSON.toUtf8(), qPrintable(MIME_TYPE));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// all requests below require a cookie to prove authentication so check that first
|
// all requests below require a cookie to prove authentication so check that first
|
||||||
bool isAuthenticated { false };
|
bool isAuthenticated { false };
|
||||||
|
|
Loading…
Reference in a new issue