Commit 46817114 authored by Volker Krause's avatar Volker Krause
Browse files

Also offer access to the full request context object

So far only the backend-specific data was available, for EFA we need the
request context type too though, in order to not have to duplicate that.
parent 0f77889d
......@@ -142,7 +142,13 @@ protected:
static void addAttributions(Reply *reply, std::vector<Attribution> &&attributions);
template <typename ReqT> inline QVariant requestContext(const ReqT &request) const
/** Extract the request context for the current backend from @p request. */
template <typename ReqT> inline RequestContext requestContext(const ReqT &request) const
{
return request.context(this);
}
/** Extract the backend-specific data from the request context for the current backend from @p request. */
template <typename ReqT> inline QVariant requestContextData(const ReqT &request) const
{
return request.context(this).backendData;
}
......
......@@ -134,7 +134,7 @@ bool HafasMgateBackend::queryJourney(const JourneyRequest &request, JourneyReply
req.insert(QStringLiteral("outDate"), dt.date().toString(QStringLiteral("yyyyMMdd")));
req.insert(QStringLiteral("outTime"), dt.time().toString(QStringLiteral("hhmmss")));
req.insert(QStringLiteral("outFrwd"), request.dateTimeMode() == JourneyRequest::Departure);
const auto ctxSrc = requestContext(request).toString();
const auto ctxSrc = requestContextData(request).toString();
if (!ctxSrc.isEmpty()) {
req.insert(QStringLiteral("ctxScr"), ctxSrc);
}
......@@ -182,7 +182,7 @@ bool HafasMgateBackend::queryStopover(const StopoverRequest &request, StopoverRe
return false;
}
const auto ctx = requestContext(request).value<HafasMgateRequestContext>();
const auto ctx = requestContextData(request).value<HafasMgateRequestContext>();
auto dt = ctx.dateTime.isValid() ? ctx.dateTime : request.dateTime();
if (timeZone().isValid()) {
dt = dt.toTimeZone(timeZone());
......
......@@ -49,7 +49,7 @@ bool NavitiaBackend::queryJourney(const JourneyRequest &req, JourneyReply *reply
return false;
}
QUrl url = requestContext(req).value<QUrl>();
QUrl url = requestContextData(req).value<QUrl>();
if (!url.isValid()) {
url.setHost(m_endpoint);
url.setPath(QStringLiteral("/v1") +
......
......@@ -145,7 +145,7 @@ bool OpenTripPlannerGraphQLBackend::queryJourney(const JourneyRequest &req, Jour
gqlReq.setVariable(QStringLiteral("toLon"), req.to().longitude());
auto dt = req.dateTime();
const auto context = requestContext(req).value<OpenTripPlannerRequestContext>();
const auto context = requestContextData(req).value<OpenTripPlannerRequestContext>();
if (context.dateTime.isValid()) {
dt = context.dateTime;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment