mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-23 07:57:51 -05:00
add custom user agent
This commit is contained in:
parent
a673fda267
commit
b9f8c38dca
2 changed files with 12 additions and 0 deletions
|
@ -206,8 +206,17 @@ std::string server::getServerAPIBaseURL() {
|
||||||
return "https://api.geode-sdk.org/v1";
|
return "https://api.geode-sdk.org/v1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string server::getServerUserAgent() {
|
||||||
|
// this may change in the future..
|
||||||
|
return fmt::format("Geode {}/{}",
|
||||||
|
Loader::get()->getVersion().toString(),
|
||||||
|
PlatformID::toShortString(GEODE_PLATFORM_TARGET)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
ServerPromise<ServerModsList> server::getMods(ModsQuery query) {
|
ServerPromise<ServerModsList> server::getMods(ModsQuery query) {
|
||||||
auto req = web::WebRequest();
|
auto req = web::WebRequest();
|
||||||
|
req.userAgent(getServerUserAgent());
|
||||||
|
|
||||||
// Always target current GD version and Loader version
|
// Always target current GD version and Loader version
|
||||||
req.param("gd", GEODE_GD_VERSION_STR);
|
req.param("gd", GEODE_GD_VERSION_STR);
|
||||||
|
@ -274,6 +283,8 @@ ServerPromise<ServerModsList> server::getMods(ModsQuery query) {
|
||||||
|
|
||||||
ServerPromise<ByteVector> server::getModLogo(std::string const& id) {
|
ServerPromise<ByteVector> server::getModLogo(std::string const& id) {
|
||||||
auto req = web::WebRequest();
|
auto req = web::WebRequest();
|
||||||
|
req.userAgent(getServerUserAgent());
|
||||||
|
|
||||||
req.param("id", id);
|
req.param("id", id);
|
||||||
return ServerPromise<ByteVector>([req = std::move(req), id](auto resolve, auto reject, auto progress, auto cancel) mutable {
|
return ServerPromise<ByteVector>([req = std::move(req), id](auto resolve, auto reject, auto progress, auto cancel) mutable {
|
||||||
req.get(getServerAPIBaseURL() + "/mods/" + id + "/logo")
|
req.get(getServerAPIBaseURL() + "/mods/" + id + "/logo")
|
||||||
|
|
|
@ -75,6 +75,7 @@ namespace server {
|
||||||
using ServerPromise = Promise<T, ServerError>;
|
using ServerPromise = Promise<T, ServerError>;
|
||||||
|
|
||||||
std::string getServerAPIBaseURL();
|
std::string getServerAPIBaseURL();
|
||||||
|
std::string getServerUserAgent();
|
||||||
ServerPromise<ServerModsList> getMods(ModsQuery query);
|
ServerPromise<ServerModsList> getMods(ModsQuery query);
|
||||||
ServerPromise<ByteVector> getModLogo(std::string const& id);
|
ServerPromise<ByteVector> getModLogo(std::string const& id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue