mirror of
https://github.com/azahar-emu/azahar.git
synced 2025-04-28 21:57:59 +03:00
Update lobby via PATCH request
This commit is contained in:
parent
527610d599
commit
57c332b0de
3 changed files with 17 additions and 2 deletions
|
@ -114,7 +114,7 @@ Common::WebResult RoomJson::Update() {
|
||||||
return Common::WebResult{Common::WebResult::Code::LibError, "Room is not registered"};
|
return Common::WebResult{Common::WebResult::Code::LibError, "Room is not registered"};
|
||||||
}
|
}
|
||||||
nlohmann::json json{{"players", room.members}};
|
nlohmann::json json{{"players", room.members}};
|
||||||
return client.PostJson(fmt::format("/lobby/{}", room_id), json.dump(), false);
|
return client.PatchJson(fmt::format("/lobby/{}", room_id), json.dump(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::WebResult RoomJson::Register() {
|
Common::WebResult RoomJson::Register() {
|
||||||
|
|
|
@ -32,7 +32,7 @@ struct Client::Impl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A generic function handles POST, GET and DELETE request together
|
/// A generic function handles POST, PATCH, GET and DELETE request together
|
||||||
Common::WebResult GenericRequest(const std::string& method, const std::string& path,
|
Common::WebResult GenericRequest(const std::string& method, const std::string& path,
|
||||||
const std::string& data, bool allow_anonymous,
|
const std::string& data, bool allow_anonymous,
|
||||||
const std::string& accept) {
|
const std::string& accept) {
|
||||||
|
@ -183,6 +183,11 @@ Common::WebResult Client::DeleteJson(const std::string& path, const std::string&
|
||||||
return impl->GenericRequest("DELETE", path, data, allow_anonymous, "application/json");
|
return impl->GenericRequest("DELETE", path, data, allow_anonymous, "application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Common::WebResult Client::PatchJson(const std::string& path, const std::string& data,
|
||||||
|
bool allow_anonymous) {
|
||||||
|
return impl->GenericRequest("PATCH", path, data, allow_anonymous, "application/json");
|
||||||
|
}
|
||||||
|
|
||||||
Common::WebResult Client::GetPlain(const std::string& path, bool allow_anonymous) {
|
Common::WebResult Client::GetPlain(const std::string& path, bool allow_anonymous) {
|
||||||
return impl->GenericRequest("GET", path, "", allow_anonymous, "text/plain");
|
return impl->GenericRequest("GET", path, "", allow_anonymous, "text/plain");
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,16 @@ public:
|
||||||
Common::WebResult DeleteJson(const std::string& path, const std::string& data,
|
Common::WebResult DeleteJson(const std::string& path, const std::string& data,
|
||||||
bool allow_anonymous);
|
bool allow_anonymous);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Patches JSON to the specified path.
|
||||||
|
* @param path the URL segment after the host address.
|
||||||
|
* @param data String of JSON data to use for the body of the PATCH request.
|
||||||
|
* @param allow_anonymous If true, allow anonymous unauthenticated requests.
|
||||||
|
* @return the result of the request.
|
||||||
|
*/
|
||||||
|
Common::WebResult PatchJson(const std::string& path, const std::string& data,
|
||||||
|
bool allow_anonymous);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a plain string from the specified path.
|
* Gets a plain string from the specified path.
|
||||||
* @param path the URL segment after the host address.
|
* @param path the URL segment after the host address.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue