增加request获取临时数据
This commit is contained in:
@@ -133,6 +133,18 @@ std::string module::request::get(const std::string& name)
|
|||||||
{
|
{
|
||||||
return m_request->reqpack()->extra()[name].to<std::string>();
|
return m_request->reqpack()->extra()[name].to<std::string>();
|
||||||
}
|
}
|
||||||
|
sol::table module::request::gets(sol::this_state s)
|
||||||
|
{
|
||||||
|
sol::state_view lua(s);
|
||||||
|
sol::table result_table = lua.create_table();
|
||||||
|
|
||||||
|
|
||||||
|
auto keys = m_request->reqpack()->extra().keys();
|
||||||
|
for (size_t i = 0; i < keys.size(); i++)
|
||||||
|
result_table[keys[i]] = m_request->reqpack()->extra()[keys[i]].to<std::string>();
|
||||||
|
|
||||||
|
return result_table;
|
||||||
|
}
|
||||||
network::http::website* module::request::website()
|
network::http::website* module::request::website()
|
||||||
{
|
{
|
||||||
return m_request->website();
|
return m_request->website();
|
||||||
@@ -160,6 +172,7 @@ void module::request::regist(sol::state* lua)
|
|||||||
"multipart_content", &module::request::multipart_content,
|
"multipart_content", &module::request::multipart_content,
|
||||||
"multipart_content_save", &module::request::multipart_content_save,
|
"multipart_content_save", &module::request::multipart_content_save,
|
||||||
"get", &module::request::get,
|
"get", &module::request::get,
|
||||||
|
"gets", &module::request::gets,
|
||||||
"set", &module::request::set,
|
"set", &module::request::set,
|
||||||
"save_body", &module::request::save_body
|
"save_body", &module::request::save_body
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ namespace module
|
|||||||
/// <param name="name"></param>
|
/// <param name="name"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
std::string get(const std::string& name);
|
std::string get(const std::string& name);
|
||||||
|
sol::table gets(sol::this_state s);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 网站指针
|
/// 网站指针
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -448,30 +448,30 @@ void fastweb::install_module_linux(fastweb::module_info info)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void fastweb::install_module_windows(fastweb::module_info info)
|
void fastweb::install_module_windows(fastweb::module_info info)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::cout<<"正在安装 `"<<info.name_en<<"` 库"<<std::endl;
|
//std::cout<<"正在安装 `"<<info.name_en<<"` 库"<<std::endl;
|
||||||
network::http::client_plus client;
|
//network::http::client_plus client;
|
||||||
if(client.get(info.download_win64) == false)
|
//if(client.get(info.download_win64) == false)
|
||||||
{
|
//{
|
||||||
std::cerr<<"下载模块压缩包失败: "<<info.download_win64<<", "<<client.last_error()<<std::endl;
|
// std::cerr<<"下载模块压缩包失败: "<<info.download_win64<<", "<<client.last_error()<<std::endl;
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
if(client.status() != 200)
|
//if(client.status() != 200)
|
||||||
{
|
//{
|
||||||
std::cerr<<"下载模块压缩包失败: "<<info.download_win64<<", status: "<<client.status()<<std::endl;
|
// std::cerr<<"下载模块压缩包失败: "<<info.download_win64<<", status: "<<client.status()<<std::endl;
|
||||||
return;
|
// return;
|
||||||
}
|
//}
|
||||||
std::string zip_filepath = ylib::file::temp_filepath()+".zip";
|
//std::string zip_filepath = ylib::file::temp_filepath()+".zip";
|
||||||
ylib::file::write(zip_filepath,client.response());
|
//ylib::file::write(zip_filepath,client.response());
|
||||||
|
|
||||||
|
//
|
||||||
std::string new_module_dirpath = m_ini.read("scripts","module_dir")+"/.install/"+info.id;
|
//std::string new_module_dirpath = m_ini.read("scripts","module_dir")+"/.install/"+info.id;
|
||||||
ylib::file::create_dir(new_module_dirpath,true);
|
//ylib::file::create_dir(new_module_dirpath,true);
|
||||||
|
|
||||||
|
|
||||||
zip_extract(zip_filepath.c_str(), new_module_dirpath.c_str(), nullptr, nullptr);
|
//zip_extract(zip_filepath.c_str(), new_module_dirpath.c_str(), nullptr, nullptr);
|
||||||
std::cerr<<"安装成功"<<std::endl;
|
//std::cerr<<"安装成功"<<std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
bool fastweb::parse_config(const std::string &ini_filepath)
|
bool fastweb::parse_config(const std::string &ini_filepath)
|
||||||
|
|||||||
Reference in New Issue
Block a user