web_backend.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 <functional>
  6. #include <future>
  7. #include <string>
  8. #include "common/common_types.h"
  9. namespace WebService {
  10. /**
  11. * Posts JSON to services.citra-emu.org.
  12. * @param url URL of the services.citra-emu.org endpoint to post data to.
  13. * @param data String of JSON data to use for the body of the POST request.
  14. * @param allow_anonymous If true, allow anonymous unauthenticated requests.
  15. * @param username Citra username to use for authentication.
  16. * @param token Citra token to use for authentication.
  17. */
  18. void PostJson(const std::string& url, const std::string& data, bool allow_anonymous,
  19. const std::string& username = {}, const std::string& token = {});
  20. /**
  21. * Gets JSON from services.citra-emu.org.
  22. * @param func A function that gets exectued when the json as a string is received
  23. * @param url URL of the services.citra-emu.org endpoint to post data to.
  24. * @param allow_anonymous If true, allow anonymous unauthenticated requests.
  25. * @param username Citra username to use for authentication.
  26. * @param token Citra token to use for authentication.
  27. * @return future that holds the return value T of the func
  28. */
  29. template <typename T>
  30. std::future<T> GetJson(std::function<T(const std::string&)> func, const std::string& url,
  31. bool allow_anonymous, const std::string& username = {},
  32. const std::string& token = {});
  33. } // namespace WebService