本文整理汇总了C++中Director::findBackend方法的典型用法代码示例。如果您正苦于以下问题:C++ Director::findBackend方法的具体用法?C++ Director::findBackend怎么用?C++ Director::findBackend使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Director
的用法示例。
在下文中一共展示了Director::findBackend方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processBackend
// }}}
// {{{ backends
bool ApiRequest::processBackend()
{
Director* director = findDirector(tokens_[0]);
if (!director) {
request_->status = x0::HttpStatus::NotFound;
request_->finish();
return true;
}
switch (requestMethod()) {
case HttpMethod::GET:
return show(director->findBackend(tokens_[2].str()));
case HttpMethod::POST:
return update(director->findBackend(tokens_[2].str()), director);
case HttpMethod::UNLOCK:
return lock(false, director->findBackend(tokens_[2].str()), director);
case HttpMethod::LOCK:
return lock(true, director->findBackend(tokens_[2].str()), director);
case HttpMethod::DELETE:
return destroy(director->findBackend(tokens_[2].str()), director);
default:
return false;
}
}
示例2: pass
void DirectorPlugin::pass(HttpRequest* r, const std::string& directorName,
const std::string& backendName) {
auto i = directors_.find(directorName);
if (i == directors_.end()) {
r->log(Severity::error,
"director.pass(): No director with name '%s' configured.",
directorName.c_str());
internalServerError(r);
return;
}
Director* director = i->second.get();
// custom backend route
Backend* backend = nullptr;
if (!backendName.empty()) {
backend = director->findBackend(backendName);
if (!backend) {
// explicit backend specified, but not found -> do not serve.
r->log(Severity::error, "director: Requested backend '%s' not found.",
backendName.c_str());
internalServerError(r);
return;
}
}
#if !defined(NDEBUG)
server().log(Severity::trace, "director: passing request to %s [backend %s].",
director->name().c_str(), backend->name().c_str());
#endif
auto rn = requestNotes(r);
rn->manager = director;
r->onPostProcess.connect(std::bind(&DirectorPlugin::addVia, this, r));
director->schedule(rn, backend);
return;
}