web_backend.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2017 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <memory>
  6. #include <string>
  7. namespace Common {
  8. struct WebResult;
  9. }
  10. namespace WebService {
  11. class Client {
  12. public:
  13. Client(std::string host, std::string username, std::string token);
  14. ~Client();
  15. /**
  16. * Posts JSON to the specified path.
  17. * @param path the URL segment after the host address.
  18. * @param data String of JSON data to use for the body of the POST request.
  19. * @param allow_anonymous If true, allow anonymous unauthenticated requests.
  20. * @return the result of the request.
  21. */
  22. Common::WebResult PostJson(const std::string& path, const std::string& data,
  23. bool allow_anonymous);
  24. /**
  25. * Gets JSON from the specified path.
  26. * @param path the URL segment after the host address.
  27. * @param allow_anonymous If true, allow anonymous unauthenticated requests.
  28. * @return the result of the request.
  29. */
  30. Common::WebResult GetJson(const std::string& path, bool allow_anonymous);
  31. /**
  32. * Deletes JSON to the specified path.
  33. * @param path the URL segment after the host address.
  34. * @param data String of JSON data to use for the body of the DELETE request.
  35. * @param allow_anonymous If true, allow anonymous unauthenticated requests.
  36. * @return the result of the request.
  37. */
  38. Common::WebResult DeleteJson(const std::string& path, const std::string& data,
  39. bool allow_anonymous);
  40. private:
  41. struct Impl;
  42. std::unique_ptr<Impl> impl;
  43. };
  44. } // namespace WebService