void server::remove_resource(const std::string& resource)
{
    std::unique_lock<std::mutex> resource_lock(m_resource_mutex, std::try_to_lock);
    const std::string clean_resource(strip_trailing_slash(resource));
    m_resources.erase(clean_resource);
    PION_LOG_INFO(m_logger, "Removed request handler for HTTP resource: " << clean_resource);
}
Ejemplo n.º 2
0
void HTTPServer::removeResource(const std::string& resource)
{
	boost::mutex::scoped_lock resource_lock(m_resource_mutex);
	const std::string clean_resource(stripTrailingSlash(resource));
	m_resources.erase(clean_resource);
	PION_LOG_INFO(m_logger, "Removed request handler for HTTP resource: " << clean_resource);
}
Ejemplo n.º 3
0
bool HTTPServer::findRequestHandler(const std::string& resource,
									RequestHandler& request_handler) const
{
	// first make sure that HTTP resources are registered
	boost::mutex::scoped_lock resource_lock(m_resource_mutex);
	if (m_resources.empty())
		return false;
	
	// iterate through each resource entry that may match the resource
	ResourceMap::const_iterator i = m_resources.upper_bound(resource);
	while (i != m_resources.begin()) {
		--i;
		// check for a match if the first part of the strings match
		if (i->first.empty() || resource.compare(0, i->first.size(), i->first) == 0) {
			// only if the resource matches the plug-in's identifier
			// or if resource is followed first with a '/' character
			if (resource.size() == i->first.size() || resource[i->first.size()]=='/') {
				request_handler = i->second;
				return true;
			}
		}
	}
	
	return false;
}
void server::add_resource(const std::string& resource,
                             request_handler_t request_handler)
{
    std::unique_lock<std::mutex> resource_lock(m_resource_mutex, std::try_to_lock);
    const std::string clean_resource(strip_trailing_slash(resource));
    m_resources.insert(std::make_pair(clean_resource, request_handler));
    PION_LOG_INFO(m_logger, "Added request handler for HTTP resource: " << clean_resource);
}
Ejemplo n.º 5
0
void HTTPServer::addResource(const std::string& resource,
							 RequestHandler request_handler)
{
	boost::mutex::scoped_lock resource_lock(m_resource_mutex);
	const std::string clean_resource(stripTrailingSlash(resource));
	m_resources.insert(std::make_pair(clean_resource, request_handler));
	PION_LOG_INFO(m_logger, "Added request handler for HTTP resource: " << clean_resource);
}
void server::add_redirect(const std::string& requested_resource,
                             const std::string& new_resource)
{
    std::unique_lock<std::mutex> resource_lock(m_resource_mutex, std::try_to_lock);
    const std::string clean_requested_resource(strip_trailing_slash(requested_resource));
    const std::string clean_new_resource(strip_trailing_slash(new_resource));
    m_redirects.insert(std::make_pair(clean_requested_resource, clean_new_resource));
    PION_LOG_INFO(m_logger, "Added redirection for HTTP resource " << clean_requested_resource << " to resource " << clean_new_resource);
}
Ejemplo n.º 7
0
void HTTPServer::addRedirect(const std::string& requested_resource,
							 const std::string& new_resource)
{
	boost::mutex::scoped_lock resource_lock(m_resource_mutex);
	const std::string clean_requested_resource(stripTrailingSlash(requested_resource));
	const std::string clean_new_resource(stripTrailingSlash(new_resource));
	m_redirects.insert(std::make_pair(clean_requested_resource, clean_new_resource));
	PION_LOG_INFO(m_logger, "Added redirection for HTTP resource " << clean_requested_resource << " to resource " << clean_new_resource);
}