22 #include "backendinfo-rest-api.h"
24 #include <webview/rest_api_manager.h>
37 :
Thread(
"BackendInfoRestApi",
Thread::OPMODE_WAITFORWAKEUP)
49 std::set<std::string> configs;
50 std::string prefix =
"/webview/backends/";
53 std::unique_ptr<Configuration::ValueIterator> i{
config->
search(prefix.c_str())};
55 std::string cfg_name = std::string(i->path()).substr(prefix.length());
56 cfg_name = cfg_name.substr(0, cfg_name.find(
"/"));
57 configs.insert(cfg_name);
60 for (
const auto &c : configs) {
68 std::string svc_prefix = prefix + c +
"/services/";
69 std::unique_ptr<Configuration::ValueIterator> i{
config->
search(svc_prefix.c_str())};
71 std::string svc_name = std::string(i->path()).substr(svc_prefix.length());
82 WebRequest::METHOD_GET,
"/?", std::bind(&BackendInfoRestApi::cb_list_backends,
this));
99 BackendInfoRestApi::cb_list_backends()
~BackendInfoRestApi()
Destructor.
BackendInfoRestApi()
Constructor.
virtual void loop()
Code to execute in the thread.
virtual void init()
Initialize the thread.
virtual void finalize()
Finalize the thread.
Backend representation for JSON transfer.
void set_kind(const std::string &kind)
Set kind value.
void set_id(const std::string &id)
Set id value.
static std::string api_version()
Get version of implemented API.
void set_apiVersion(const std::string &apiVersion)
Set apiVersion value.
void set_name(const std::string &name)
Set name value.
void addto_services(const std::shared_ptr< Service > &&services)
Add element to services array.
void set_url(const std::string &url)
Set url value.
Service representation for JSON transfer.
void set_name(const std::string &name)
Set name value.
void set_url(const std::string &url)
Set url value.
void push_back(M &m)
Add item at the back of the container.
Configuration * config
This is the Configuration member used to access the configuration.
virtual ValueIterator * search(const char *path)=0
Iterator with search results.
virtual std::string get_string(const char *path)=0
Get value from configuration which is of type string.
Logger * logger
This is the Logger member used to access the logger.
Thread class encapsulation of pthreads.
WebviewRestApiManager * webview_rest_api_manager
Webview REST API manager.
void unregister_api(WebviewRestApi *api)
Remove a request processor.
void register_api(WebviewRestApi *api)
Add a REST API.
Webview REST API component.
void add_handler(WebRequest::Method method, std::string path, Handler handler)
Add handler function.
Fawkes library namespace.