本文整理汇总了C++中ApiRequest::getTokenParam方法的典型用法代码示例。如果您正苦于以下问题:C++ ApiRequest::getTokenParam方法的具体用法?C++ ApiRequest::getTokenParam怎么用?C++ ApiRequest::getTokenParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiRequest
的用法示例。
在下文中一共展示了ApiRequest::getTokenParam方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleUpdateProfile
api_return ShareProfileApi::handleUpdateProfile(ApiRequest& aRequest) {
const auto& reqJson = aRequest.getRequestBody();
auto token = aRequest.getTokenParam(0);
if (token == SP_HIDDEN) {
aRequest.setResponseErrorStr("Hidden profile can't be edited");
return websocketpp::http::status_code::not_found;
}
auto profile = ShareManager::getInstance()->getShareProfile(token);
if (!profile) {
aRequest.setResponseErrorStr("Profile not found");
return websocketpp::http::status_code::not_found;
}
parseProfile(profile, reqJson);
ShareManager::getInstance()->updateProfile(profile);
return websocketpp::http::status_code::ok;
}
示例2: handleRemoveProfile
api_return ShareProfileApi::handleRemoveProfile(ApiRequest& aRequest) {
auto token = aRequest.getTokenParam(0);
if (token == SP_HIDDEN) {
aRequest.setResponseErrorStr("Hidden profile can't be deleted");
return websocketpp::http::status_code::bad_request;
}
if (token == SETTING(DEFAULT_SP)) {
aRequest.setResponseErrorStr("The default profile can't be deleted (set another profile as default first)");
return websocketpp::http::status_code::bad_request;
}
if (!ShareManager::getInstance()->getShareProfile(token)) {
aRequest.setResponseErrorStr("Profile not found");
return websocketpp::http::status_code::not_found;
}
ShareManager::getInstance()->removeProfile(token);
return websocketpp::http::status_code::ok;
}