34 using base::SettingBase;
35 using base::SettingManager;
44 static const std::string GetAllSettings() {
47 const SettingManager::SettingMap settings = SettingManager::GetAllSettings();
48 for (SettingManager::SettingMap::const_iterator it = settings.begin();
49 it != settings.end(); ++it) {
50 const std::string type_desc_string =
51 it->second->GetTypeDescriptor().empty() ?
" " :
52 it->second->GetTypeDescriptor();
53 const std::string doc_string =
54 it->second->GetDocString().empty() ?
" " : it->second->GetDocString();
68 HttpServer::QueryMap::const_iterator name_it = args.find(
"name");
69 HttpServer::QueryMap::const_iterator value_it = args.find(
"value");
72 if (name_it != args.end() && value_it != args.end()) {
73 SettingBase* setting = SettingManager::GetSetting(name_it->second);
77 if (setting && setting->FromString(value_it->second))
78 response = setting->ToString();
87 :
HttpServer::RequestHandler(
"/ion/settings") {
88 IonRemoteSettingsRoot::RegisterAssetsOnce();
95 std::string* content_type) {
96 const std::string path = path_in.empty() ?
"index.html" : path_in;
98 if (path ==
"get_all_settings") {
99 return GetAllSettings();
100 }
else if (path ==
"set_setting_value") {
101 return SetSettingValue(args);
104 "ion/settings/" + path);
106 return std::string();
110 *content_type =
"text/html";
bool IsInvalidReference(const T &value)
IsInvalidReference() returns true if a passed const reference of type T has an address of InvalidRefe...
const std::string HandleRequest(const std::string &path, const HttpServer::QueryMap &args, std::string *content_type) override
The HandleRequest() function is passed the path (relative to its base path) of the file or directory ...
static const std::string & GetFileData(const std::string &filename)
Returns the data of the passed filename if the manager contains it.
~SettingHandler() override
bool EndsWith(const std::string &target, const std::string &end)
Returns whether target ends with end.
std::map< std::string, std::string > QueryMap
ION_API std::string UrlEncodeString(const std::string &str)
Returns a URL-encoded version of a string.
ION_REGISTER_ASSETS(IonRemoteSettingsRoot)
Copyright 2016 Google Inc.