本文整理汇总了C++中HTTPServer::FindAction方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPServer::FindAction方法的具体用法?C++ HTTPServer::FindAction怎么用?C++ HTTPServer::FindAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPServer
的用法示例。
在下文中一共展示了HTTPServer::FindAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConfigException
//.........这里部分代码省略.........
Sinkhole::ConfigurationBlock &ab = b.GetBlock("action", k);
try
{
std::string aname = ab.GetValue("name");
std::string sname = ab.GetValue("server-name");
std::vector<HTTPVhost> vhosts;
for (int m = 0, n = ab.CountBlock("vhost"); m < n; ++m)
{
Sinkhole::ConfigurationBlock &vb = ab.GetBlock("vhost", m);
std::string vname = vb.GetValue("name");
HTTPVhost::Type t = HTTPVhost::TYPE_SERVE;
std::string data;
try { data = vb.GetValue("serve"); }
catch (const Sinkhole::ConfigException &)
{
t = HTTPVhost::TYPE_ROOT;
try { data = vb.GetValue("root"); }
catch (const Sinkhole::ConfigException &)
{
throw Sinkhole::ConfigException("You must define either serve or root");
}
}
HTTPVhost vhost;
vhost.name = vname;
vhost.data = data;
vhost.type = t;
vhosts.push_back(vhost);
}
HTTPVhost::Type t = HTTPVhost::TYPE_SERVE;
std::string data;
try { data = ab.GetValue("serve"); }
catch (const Sinkhole::ConfigException &)
{
t = HTTPVhost::TYPE_ROOT;
try { data = ab.GetValue("root"); }
catch (const Sinkhole::ConfigException &)
{
throw Sinkhole::ConfigException("You must define either serve or root");
}
}
HTTPAction *a = new HTTPAction();
a->vhosts = vhosts;
a->name = aname;
a->server_name = sname;
a->data = data;
a->type = t;
s->actions.insert(std::make_pair(a->name, a));
}
catch (const Sinkhole::ConfigException &ex)
{
Sinkhole::Log(Sinkhole::LOG_ERROR) << "Error loading http:action for " << name << ": " << ex.GetReason();
}
}
for (int k = 0, l = b.CountBlock("class"); k < l; ++k)
{
Sinkhole::ConfigurationBlock &cb = b.GetBlock("class", k);
try
{
std::vector<Sinkhole::cidr> sources;
for (int m = 0, n = cb.CountBlock("source"); m < n; ++m)
{
Sinkhole::ConfigurationBlock &cbs = cb.GetBlock("source", m);
Sinkhole::cidr range(cbs.GetValue("addr"));
sources.push_back(range);
}
std::string action = cb.GetValue("action");
HTTPAction *a = s->FindAction(action);
if (a == NULL)
throw Sinkhole::ConfigException("Unknown action \"" + action + "\"");
HTTPClass *c = new HTTPClass(a);
c->sources = sources;
s->classes.push_back(c);
}
catch (const Sinkhole::SocketException &ex)
{
Sinkhole::Log(Sinkhole::LOG_ERROR) << "Error loading http:class:source for " << name << ": " << ex.GetReason();
}
catch (const Sinkhole::ConfigException &ex)
{
Sinkhole::Log(Sinkhole::LOG_ERROR) << "Error loading http:class:source for " << name << ": " << ex.GetReason();
}
}
}
catch (const Sinkhole::ConfigException &ex)
{
Sinkhole::Log(Sinkhole::LOG_ERROR) << "Error loading http block " << i << ": " << ex.GetReason();
}
}
}