refactor: override / mask static make
functions for ApiDownload
Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
@ -1,8 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
/*
|
||||
* Prism Launcher - Minecraft Launcher
|
||||
* Copyright (c) 2022 flowln <flowlnlnln@gmail.com>
|
||||
* Copyright (C) 2022 Sefa Eyeoglu <contact@scrumplex.net>
|
||||
* Copyright (C) 2023 Rachel Powers <508861+Ryex@users.noreply.github.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -21,9 +19,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "net/HeaderProxy.h"
|
||||
#include "Application.h"
|
||||
#include "BuildConfig.h"
|
||||
#include "net/HeaderProxy.h"
|
||||
|
||||
namespace Net {
|
||||
|
||||
@ -33,19 +31,19 @@ class ApiHeaderProxy : public HeaderProxy {
|
||||
virtual ~ApiHeaderProxy() = default;
|
||||
|
||||
public:
|
||||
virtual QList<HeaderPair> headers(const QNetworkRequest& request) const override
|
||||
{
|
||||
QList<HeaderPair> hdrs;
|
||||
if (APPLICATION->capabilities() & Application::SupportsFlame && request.url().host() == QUrl(BuildConfig.FLAME_BASE_URL).host()) {
|
||||
hdrs.append({ "x-api-key", APPLICATION->getFlameAPIKey().toUtf8() });
|
||||
} else if (request.url().host() == QUrl(BuildConfig.MODRINTH_PROD_URL).host() ||
|
||||
request.url().host() == QUrl(BuildConfig.MODRINTH_STAGING_URL).host()) {
|
||||
QString token = APPLICATION->getModrinthAPIToken();
|
||||
if (!token.isNull())
|
||||
hdrs.append({ "Authorization", token.toUtf8() });
|
||||
}
|
||||
return hdrs;
|
||||
virtual QList<HeaderPair> headers(const QNetworkRequest& request) const override {
|
||||
QList<HeaderPair> hdrs;
|
||||
if (APPLICATION->capabilities() & Application::SupportsFlame && request.url().host() == QUrl(BuildConfig.FLAME_BASE_URL).host()) {
|
||||
hdrs.append({ "x-api-key", APPLICATION->getFlameAPIKey().toUtf8() });
|
||||
} else if (request.url().host() == QUrl(BuildConfig.MODRINTH_PROD_URL).host() ||
|
||||
request.url().host() == QUrl(BuildConfig.MODRINTH_STAGING_URL).host()) {
|
||||
QString token = APPLICATION->getModrinthAPIToken();
|
||||
if (!token.isNull())
|
||||
hdrs.append({ "Authorization", token.toUtf8() });
|
||||
}
|
||||
return hdrs;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
} // namespace Net
|
||||
|
Reference in New Issue
Block a user