mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-27 01:45:35 -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";
|
||||
}
|
||||
|
||||
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) {
|
||||
auto req = web::WebRequest();
|
||||
req.userAgent(getServerUserAgent());
|
||||
|
||||
// Always target current GD version and Loader version
|
||||
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) {
|
||||
auto req = web::WebRequest();
|
||||
req.userAgent(getServerUserAgent());
|
||||
|
||||
req.param("id", id);
|
||||
return ServerPromise<ByteVector>([req = std::move(req), id](auto resolve, auto reject, auto progress, auto cancel) mutable {
|
||||
req.get(getServerAPIBaseURL() + "/mods/" + id + "/logo")
|
||||
|
|
|
@ -75,6 +75,7 @@ namespace server {
|
|||
using ServerPromise = Promise<T, ServerError>;
|
||||
|
||||
std::string getServerAPIBaseURL();
|
||||
std::string getServerUserAgent();
|
||||
ServerPromise<ServerModsList> getMods(ModsQuery query);
|
||||
ServerPromise<ByteVector> getModLogo(std::string const& id);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue