CARTA Backend
The backend component of CARTA
Loading...
Searching...
No Matches
carta::HttpServer Class Reference

#include <HttpServer.h>

Collaboration diagram for carta::HttpServer:
[legend]

Public Member Functions

 HttpServer (std::shared_ptr< SessionManager > session_manager, fs::path root_folder, fs::path user_directory, std::string auth_token, bool read_only_mode=false, bool enable_frontend=true, bool enable_database=true, bool enable_scripting=false, bool enable_runtime_config=true, std::string url_prefix="")
 
bool CanServeFrontend ()
 
void RegisterRoutes ()
 

Static Public Member Functions

static std::string GetFileUrlString (std::vector< std::string > files)
 

Protected Member Functions

nlohmann::json GetExistingPreferences ()
 
std::string_view UpdatePreferencesFromString (const std::string &buffer)
 
std::string_view ClearPreferencesFromString (const std::string &buffer)
 
nlohmann::json GetExistingObjectList (const std::string &object_type)
 
nlohmann::json GetExistingObjects (const std::string &object_type)
 
nlohmann::json GetExistingObject (const std::string &object_type, const std::string &object_name)
 
std::string_view SetObjectFromString (const std::string &object_type, const std::string &buffer)
 
std::string_view ClearObjectFromString (const std::string &object_type, const std::string &buffer)
 
std::string_view SendScriptingRequest (const std::string &buffer, int &session_id, ScriptingResponseCallback callback, ScriptingSessionClosedCallback session_closed_callback, ScriptingRequestHandler request_handler)
 
std::string_view OnScriptingResponse (std::string &response_buffer, const bool &success, const std::string &message, const std::string &response)
 
void OnScriptingAbort (int session_id, uint32_t scripting_request_id)
 

Private Member Functions

bool IsAuthenticated (Req *req)
 
void AddNoCacheHeaders (Res *res)
 
void AddCorsHeaders (Res *res)
 
bool WritePreferencesFile (nlohmann::json &obj)
 
bool WriteObjectFile (const std::string &object_type, const std::string &object_name, nlohmann::json &obj)
 
void WaitForData (Res *res, Req *req, const std::function< void(const std::string &)> &callback)
 
void HandleStaticRequest (Res *res, Req *req)
 
void HandleGetConfig (Res *res, Req *req)
 
void HandleGetPreferences (Res *res, Req *req)
 
void HandleSetPreferences (Res *res, Req *req)
 
void HandleClearPreferences (Res *res, Req *req)
 
void HandleGetObjectList (const std::string &object_type, Res *res, Req *req)
 
void HandleGetObject (const std::string &object_type, Res *res, Req *req)
 
void HandleGetObjects (const std::string &object_type, Res *res, Req *req)
 
void HandleSetObject (const std::string &object_type, Res *res, Req *req)
 
void HandleClearObject (const std::string &object_type, Res *res, Req *req)
 
void HandleScriptingAction (Res *res, Req *req)
 
void NotImplemented (Res *res, Req *req)
 
void DefaultSuccess (Res *res, Req *req)
 

Static Private Member Functions

static bool IsValidFrontendFolder (fs::path folder)
 

Private Attributes

fs::path _http_root_folder
 
fs::path _config_folder
 
bool _frontend_found
 
std::string _auth_token
 
bool _read_only_mode
 
bool _enable_frontend
 
bool _enable_database
 
bool _enable_scripting
 
bool _enable_runtime_config
 
std::string _url_prefix
 
std::shared_ptr< SessionManager_session_manager
 

Static Private Attributes

static uint32_t _scripting_request_id = 0
 

Constructor & Destructor Documentation

◆ HttpServer()

carta::HttpServer::HttpServer ( std::shared_ptr< SessionManager session_manager,
fs::path  root_folder,
fs::path  user_directory,
std::string  auth_token,
bool  read_only_mode = false,
bool  enable_frontend = true,
bool  enable_database = true,
bool  enable_scripting = false,
bool  enable_runtime_config = true,
std::string  url_prefix = "" 
)
Here is the call graph for this function:

Member Function Documentation

◆ AddCorsHeaders()

void carta::HttpServer::AddCorsHeaders ( Res res)
private
Here is the caller graph for this function:

◆ AddNoCacheHeaders()

void carta::HttpServer::AddNoCacheHeaders ( Res res)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CanServeFrontend()

bool carta::HttpServer::CanServeFrontend ( )
inline

◆ ClearObjectFromString()

std::string_view carta::HttpServer::ClearObjectFromString ( const std::string &  object_type,
const std::string &  buffer 
)
protected
Here is the caller graph for this function:

◆ ClearPreferencesFromString()

std::string_view carta::HttpServer::ClearPreferencesFromString ( const std::string &  buffer)
protected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ DefaultSuccess()

void carta::HttpServer::DefaultSuccess ( Res res,
Req req 
)
private
Here is the caller graph for this function:

◆ GetExistingObject()

nlohmann::json carta::HttpServer::GetExistingObject ( const std::string &  object_type,
const std::string &  object_name 
)
protected
Here is the caller graph for this function:

◆ GetExistingObjectList()

nlohmann::json carta::HttpServer::GetExistingObjectList ( const std::string &  object_type)
protected
Here is the caller graph for this function:

◆ GetExistingObjects()

nlohmann::json carta::HttpServer::GetExistingObjects ( const std::string &  object_type)
protected
Here is the caller graph for this function:

◆ GetExistingPreferences()

json carta::HttpServer::GetExistingPreferences ( )
protected
Here is the caller graph for this function:

◆ GetFileUrlString()

std::string carta::HttpServer::GetFileUrlString ( std::vector< std::string >  files)
static
Here is the call graph for this function:

◆ HandleClearObject()

void carta::HttpServer::HandleClearObject ( const std::string &  object_type,
Res res,
Req req 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleClearPreferences()

void carta::HttpServer::HandleClearPreferences ( Res res,
Req req 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleGetConfig()

void carta::HttpServer::HandleGetConfig ( Res res,
Req req 
)
private
Here is the caller graph for this function:

◆ HandleGetObject()

void carta::HttpServer::HandleGetObject ( const std::string &  object_type,
Res res,
Req req 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleGetObjectList()

void carta::HttpServer::HandleGetObjectList ( const std::string &  object_type,
Res res,
Req req 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleGetObjects()

void carta::HttpServer::HandleGetObjects ( const std::string &  object_type,
Res res,
Req req 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleGetPreferences()

void carta::HttpServer::HandleGetPreferences ( Res res,
Req req 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleScriptingAction()

void carta::HttpServer::HandleScriptingAction ( Res res,
Req req 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleSetObject()

void carta::HttpServer::HandleSetObject ( const std::string &  object_type,
Res res,
Req req 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleSetPreferences()

void carta::HttpServer::HandleSetPreferences ( Res res,
Req req 
)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleStaticRequest()

void carta::HttpServer::HandleStaticRequest ( Res res,
Req req 
)
private
Here is the caller graph for this function:

◆ IsAuthenticated()

bool carta::HttpServer::IsAuthenticated ( Req req)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsValidFrontendFolder()

bool carta::HttpServer::IsValidFrontendFolder ( fs::path  folder)
staticprivate
Here is the caller graph for this function:

◆ NotImplemented()

void carta::HttpServer::NotImplemented ( Res res,
Req req 
)
private
Here is the caller graph for this function:

◆ OnScriptingAbort()

void carta::HttpServer::OnScriptingAbort ( int  session_id,
uint32_t  scripting_request_id 
)
protected
Here is the caller graph for this function:

◆ OnScriptingResponse()

std::string_view carta::HttpServer::OnScriptingResponse ( std::string &  response_buffer,
const bool &  success,
const std::string &  message,
const std::string &  response 
)
protected
Here is the caller graph for this function:

◆ RegisterRoutes()

void carta::HttpServer::RegisterRoutes ( )
Here is the call graph for this function:

◆ SendScriptingRequest()

std::string_view carta::HttpServer::SendScriptingRequest ( const std::string &  buffer,
int &  session_id,
ScriptingResponseCallback  callback,
ScriptingSessionClosedCallback  session_closed_callback,
ScriptingRequestHandler  request_handler 
)
protected
Here is the caller graph for this function:

◆ SetObjectFromString()

std::string_view carta::HttpServer::SetObjectFromString ( const std::string &  object_type,
const std::string &  buffer 
)
protected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdatePreferencesFromString()

std::string_view carta::HttpServer::UpdatePreferencesFromString ( const std::string &  buffer)
protected
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WaitForData()

void carta::HttpServer::WaitForData ( Res res,
Req req,
const std::function< void(const std::string &)> &  callback 
)
private
Here is the caller graph for this function:

◆ WriteObjectFile()

bool carta::HttpServer::WriteObjectFile ( const std::string &  object_type,
const std::string &  object_name,
nlohmann::json &  obj 
)
private
Here is the caller graph for this function:

◆ WritePreferencesFile()

bool carta::HttpServer::WritePreferencesFile ( nlohmann::json &  obj)
private
Here is the caller graph for this function:

Member Data Documentation

◆ _auth_token

std::string carta::HttpServer::_auth_token
private

◆ _config_folder

fs::path carta::HttpServer::_config_folder
private

◆ _enable_database

bool carta::HttpServer::_enable_database
private

◆ _enable_frontend

bool carta::HttpServer::_enable_frontend
private

◆ _enable_runtime_config

bool carta::HttpServer::_enable_runtime_config
private

◆ _enable_scripting

bool carta::HttpServer::_enable_scripting
private

◆ _frontend_found

bool carta::HttpServer::_frontend_found
private

◆ _http_root_folder

fs::path carta::HttpServer::_http_root_folder
private

◆ _read_only_mode

bool carta::HttpServer::_read_only_mode
private

◆ _scripting_request_id

uint32_t carta::HttpServer::_scripting_request_id = 0
staticprivate

◆ _session_manager

std::shared_ptr<SessionManager> carta::HttpServer::_session_manager
private

◆ _url_prefix

std::string carta::HttpServer::_url_prefix
private

The documentation for this class was generated from the following files: