wip match functionality
This commit is contained in:
@@ -240,13 +240,16 @@ UhttpServer::UhttpServer(void) : m_ctx(NULL),
|
||||
*/
|
||||
UhttpServer::~UhttpServer(void)
|
||||
{
|
||||
ControllerIterator it;
|
||||
ConnectionIterator the_cnx_it;
|
||||
for (it = m_controller_array.begin(); it != m_controller_array.end(); ++it)
|
||||
|
||||
for (std::vector< WebController *>::iterator the_it = m_controllers.begin();
|
||||
the_it != m_controllers.end(); ++the_it)
|
||||
{
|
||||
delete it->second;
|
||||
delete *the_it;
|
||||
}
|
||||
|
||||
m_controllers.clear();
|
||||
|
||||
for (the_cnx_it = m_connections.begin(); the_cnx_it != m_connections.end(); ++the_cnx_it)
|
||||
{
|
||||
delete the_cnx_it->second;
|
||||
@@ -285,13 +288,15 @@ struct ubus_context *UhttpServer::get_context(void)
|
||||
*/
|
||||
bool UhttpServer::check_url(const std::string &an_url)
|
||||
{
|
||||
std::list<std::string>::iterator the_it;
|
||||
// printf("UhttpServer::check_url: %s\n", an_url.c_str());
|
||||
std::vector<WebController *>::iterator the_it;
|
||||
printf("UhttpServer::check_url: %s\n", an_url.c_str());
|
||||
|
||||
for (the_it = m_path_list.begin(); the_it != m_path_list.end(); the_it++)
|
||||
for (the_it = m_controllers.begin(); the_it != m_controllers.end(); ++the_it)
|
||||
{
|
||||
if (an_url.find(*the_it) != std::string::npos)
|
||||
if ( (*the_it)->find(an_url))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -307,7 +312,7 @@ void UhttpServer::handle_request(struct client *a_cl, const std::string &an_url,
|
||||
std::string the_url, the_parameters;
|
||||
std::size_t the_pos;
|
||||
WebController *the_controller;
|
||||
// printf("uhttp_server_handle_request : url: <%s> client: %p\n", an_url.c_str(), a_cl);
|
||||
printf("uhttp_server_handle_request : url: <%s> client: %p\n", an_url.c_str(), a_cl);
|
||||
|
||||
// Check if parameters are present on the url.
|
||||
the_pos = an_url.find_first_of("?", 0);
|
||||
@@ -323,7 +328,8 @@ void UhttpServer::handle_request(struct client *a_cl, const std::string &an_url,
|
||||
the_url = an_url;
|
||||
}
|
||||
|
||||
the_controller = m_controller_array[the_url];
|
||||
#warning todo
|
||||
// the_controller = m_controller_array[the_url];
|
||||
if (the_controller == NULL)
|
||||
{
|
||||
std::string the_msg;
|
||||
@@ -657,10 +663,11 @@ int UhttpServer::add_controller(const std::string &an_uri, WebController *a_cont
|
||||
return -1;
|
||||
|
||||
a_controller->set_name(an_uri);
|
||||
m_controller_array[an_uri] = a_controller;
|
||||
//m_controller_array[an_uri] = a_controller;
|
||||
|
||||
// printf("add: an_uri:%s\n", an_uri.c_str());
|
||||
printf("add: an_uri:%s\n", an_uri.c_str());
|
||||
|
||||
#if 0
|
||||
// Keep a list of the API root. to check if a controller is managed by this plugin or not.
|
||||
the_pos = an_uri.find_first_of("/", 1);
|
||||
if (the_pos != std::string::npos)
|
||||
@@ -672,7 +679,7 @@ int UhttpServer::add_controller(const std::string &an_uri, WebController *a_cont
|
||||
m_path_list.push_back(the_path);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user