34 using Ptr = std::shared_ptr<Functions::Function>;
36 enum class ResponseType
44 Function(std::string endpoint, HTTP::EnumMethods method, ResponseType response_type = ResponseType::kJSON);
46 std::string get_endpoint()
const {
return endpoint_; }
47 std::string get_target()
const {
return target_; }
48 bool get_error()
const {
return error_; }
49 std::string get_error_message()
const {
return error_message_; }
50 bool get_remove_file_on_modify()
const {
return remove_file_on_modify_; }
51 ResponseType get_response_type()
const {
return response_type_; }
52 HTTP::EnumMethods get_method()
const {
return method_; }
55 auto& var = current_user_;
58 std::vector<Action::Ptr>& get_actions()
68 Files::FileManager::Ptr& get_file_manager()
70 auto& var = file_manager_;
73 std::vector<Query::Parameter::Ptr>& get_parameters()
75 auto& var = parameters_;
79 void set_endpoint(std::string endpoint) { endpoint_ = endpoint; }
80 void set_target(std::string target) { target_ = target; }
81 void set_remove_file_on_modify(
bool remove_file_on_modify) { remove_file_on_modify_ = remove_file_on_modify; }
82 void set_method(HTTP::EnumMethods type) { method_ = type; }
83 void set_response_type(ResponseType response_type) { response_type_ = response_type; }
85 std::vector<Query::Parameter::Ptr>::iterator GetParameter_(std::string name);
86 Action::Ptr AddAction_(std::string identifier);
87 std::vector<Action::Ptr>::iterator GetAction_(std::string identifier);
88 void Process_(HTTP::Request::HTTPServerRequestPtr request, HTTP::Request::HTTPServerResponsePtr response);
89 bool ProcessAction_(Action::Ptr action);
90 bool ProcessJSON_(JSON::Object::Ptr& json_result);
91 bool ProcessFile_(std::string& filepath);
92 void DownloadProcess_(std::string& filepath);
93 void UploadProcess_();
94 void ModifyProcess_(std::string& filepath);
95 void RemoveProcess_(std::string& filepath);
96 void SetupCustomProcess_(std::function<
void(
Function&)> custom_process);
97 void IdentifyParameters_(Functions::Action::Ptr action);
100 void Setup_(HTTP::Request::HTTPServerRequestPtr request, HTTP::Request::HTTPServerResponsePtr response);
103 std::string endpoint_;
106 std::string error_message_;
107 bool remove_file_on_modify_;
108 ResponseType response_type_;
109 HTTP::EnumMethods method_;
111 std::vector<Action::Ptr> actions_;
113 Files::FileManager::Ptr file_manager_;
114 std::function<void(
Function&)> custom_process_;
115 std::vector<Query::Parameter::Ptr> parameters_;