优化兼容
This commit is contained in:
@@ -36,7 +36,7 @@ namespace ylib
|
||||
// 请求类型
|
||||
network::http::method method;
|
||||
// 回调函数
|
||||
std::function<void(network::http::request*, network::http::response*)> callback;
|
||||
std::function<void(network::http::request*, network::http::response*,void *extra)> callback;
|
||||
// 控制器。为控制器则启动下面两个属性
|
||||
bool controller;
|
||||
// 创建控制器类指针
|
||||
@@ -49,6 +49,8 @@ namespace ylib
|
||||
// LUA虚拟机初始化回调
|
||||
std::function<void(sol::state& state)> lua_init_state;
|
||||
#endif
|
||||
// 附加数据
|
||||
void* extra = nullptr;
|
||||
};
|
||||
/*************************************************************************
|
||||
* class:路由中专服务
|
||||
@@ -94,9 +96,10 @@ namespace ylib
|
||||
* 同一地址不允许订阅两次
|
||||
******************************************************************/
|
||||
void subscribe(
|
||||
const std::string& path,
|
||||
const std::string& path,
|
||||
network::http::method method,
|
||||
std::function<void(network::http::request*, network::http::response*)> callback
|
||||
std::function<void(network::http::request*, network::http::response*, void*)> callback,
|
||||
void* extra = nullptr
|
||||
);
|
||||
#define SUBSCRIBE(ROUTER,CONTROLLER,FUNCTION,PATH,METHOD) ROUTER->subscribe([]()->void*{return new CONTROLLER;},(ylib::network::http::HTTP_CTR_FUNCTION)&CONTROLLER::FUNCTION,PATH,METHOD)
|
||||
|
||||
|
||||
@@ -456,7 +456,7 @@ std::string ylib::mysql::result::field_name(uint32 index)
|
||||
|
||||
std::string ylib::mysql::result::field_type(uint32 index)
|
||||
{
|
||||
return strutils::change_case(RESULT_SET->getMetaData()->getColumnTypeName(index));
|
||||
return strutils::change_case(RESULT_SET->getMetaData()->getColumnTypeName(index),false);
|
||||
}
|
||||
|
||||
std::string ylib::mysql::result::field_type(const std::string& name)
|
||||
|
||||
@@ -81,7 +81,7 @@ bool network::http::cdn::start(const cdn_config& config){
|
||||
else
|
||||
{
|
||||
std::cout<<"CDN:Node start"<<std::endl;
|
||||
website()->router()->subscribe("/info",network::http::GET,[&](network::http::request* request,network::http::response* response){
|
||||
website()->router()->subscribe("/info",network::http::GET,[&](network::http::request* request,network::http::response* response,void* extra){
|
||||
ylib::json rep;
|
||||
std::string value_key;
|
||||
if(request->header("key",value_key) == false || m_cdn_node_key != value_key){
|
||||
|
||||
@@ -74,7 +74,7 @@ network::http::interceptor* network::http::router::interceptor(){
|
||||
return m_interceptor;
|
||||
}
|
||||
|
||||
void network::http::router::subscribe(const std::string &path, network::http::method method, std::function<void(network::http::request*,network::http::response*)> callback)
|
||||
void network::http::router::subscribe(const std::string &path, network::http::method method, std::function<void(network::http::request*,network::http::response*,void*)> callback, void* extra)
|
||||
{
|
||||
#if HTTP_ROUTER_PRINT == 1
|
||||
ylib::log->info("[subscribe][func] express:"+path+" method:"+method_to_string(method),"router");
|
||||
@@ -84,6 +84,7 @@ void network::http::router::subscribe(const std::string &path, network::http::me
|
||||
svie->method = method;
|
||||
svie->express = std::regex(path.c_str());
|
||||
svie->callback = callback;
|
||||
svie->extra = extra;
|
||||
m_subscribe.append(svie);
|
||||
}
|
||||
void network::http::router::subscribe(
|
||||
@@ -197,7 +198,7 @@ void ylib::network::http::router::__thread_callback(reqpack* rp)
|
||||
//普通回调
|
||||
if (sub->callback != nullptr)
|
||||
{
|
||||
sub->callback(rp->request(), rp->response());
|
||||
sub->callback(rp->request(), rp->response(),sub->extra);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user