当前位置: 首页>>代码示例>>C++>>正文


C++ ApiRequest::getRequestBody方法代码示例

本文整理汇总了C++中ApiRequest::getRequestBody方法的典型用法代码示例。如果您正苦于以下问题:C++ ApiRequest::getRequestBody方法的具体用法?C++ ApiRequest::getRequestBody怎么用?C++ ApiRequest::getRequestBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ApiRequest的用法示例。


在下文中一共展示了ApiRequest::getRequestBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handleAddFileBundle

api_return QueueApi::handleAddFileBundle(ApiRequest& aRequest) {
    const auto& reqJson = aRequest.getRequestBody();

    string targetDirectory, targetFileName;
    TargetUtil::TargetType targetType;
    QueueItemBase::Priority prio;
    Deserializer::deserializeDownloadParams(aRequest.getRequestBody(), targetDirectory, targetFileName, targetType, prio);

    BundlePtr b = nullptr;
    try {
        b = QueueManager::getInstance()->createFileBundle(
                targetDirectory + targetFileName,
                JsonUtil::getField<int64_t>("size", reqJson, false),
                Deserializer::deserializeTTH(reqJson),
                Deserializer::deserializeHintedUser(reqJson),
                JsonUtil::getField<time_t>("time", reqJson, false),
                0,
                prio
            );
    }
    catch (const Exception& e) {
        aRequest.setResponseErrorStr(e.getError());
        return websocketpp::http::status_code::internal_server_error;
    }

    if (b) {
        json retJson = {
            { "id", b->getToken() }
        };

        aRequest.setResponseBody(retJson);
    }

    return websocketpp::http::status_code::ok;
}
开发者ID:fhede,项目名称:airdcpp-webclient,代码行数:35,代码来源:QueueApi.cpp

示例2: handleAddFileBundle

	api_return QueueApi::handleAddFileBundle(ApiRequest& aRequest) {
		const auto& reqJson = aRequest.getRequestBody();

		string targetDirectory, targetFileName;
		Priority prio;
		Deserializer::deserializeDownloadParams(aRequest.getRequestBody(), aRequest.getSession(), targetDirectory, targetFileName, prio);

		BundleAddInfo bundleAddInfo;
		try {
			bundleAddInfo = QueueManager::getInstance()->createFileBundle(
				targetDirectory + targetFileName,
				JsonUtil::getField<int64_t>("size", reqJson, false),
				Deserializer::deserializeTTH(reqJson),
				Deserializer::deserializeHintedUser(reqJson),
				JsonUtil::getField<time_t>("time", reqJson, false),
				0,
				prio
			);
		} catch (const Exception& e) {
			aRequest.setResponseErrorStr(e.getError());
			return websocketpp::http::status_code::internal_server_error;
		}

		aRequest.setResponseBody(Serializer::serializeBundleAddInfo(bundleAddInfo));
		return websocketpp::http::status_code::ok;
	}
开发者ID:airdcpp,项目名称:airdcpp-webapi,代码行数:26,代码来源:QueueApi.cpp

示例3: handleRemoveTarget

	api_return QueueApi::handleRemoveTarget(ApiRequest& aRequest) {
		auto removeFinished = JsonUtil::getOptionalFieldDefault<bool>("remove_finished", aRequest.getRequestBody(), false);
		auto path = JsonUtil::getField<string>("target", aRequest.getRequestBody(), false);
		if (!QueueManager::getInstance()->removeFile(path, removeFinished)) {
			aRequest.setResponseErrorStr("File not found");
			return websocketpp::http::status_code::bad_request;
		}

		return websocketpp::http::status_code::ok;
	}
开发者ID:airdcpp,项目名称:airdcpp-webapi,代码行数:10,代码来源:QueueApi.cpp

示例4: WEBCFG

	websocketpp::http::status_code::value SessionApi::handleLogin(ApiRequest& aRequest, bool aIsSecure, const WebSocketPtr& aSocket, const string& aIP) {
		const auto& reqJson = aRequest.getRequestBody();

		auto username = JsonUtil::getField<string>("username", reqJson, false);
		auto password = JsonUtil::getField<string>("password", reqJson, false);

		auto inactivityMinutes = JsonUtil::getOptionalFieldDefault<uint64_t>("max_inactivity", reqJson, WEBCFG(DEFAULT_SESSION_IDLE_TIMEOUT).uint64());
		auto userSession = JsonUtil::getOptionalFieldDefault<bool>("user_session", reqJson, false);

		auto session = WebServerManager::getInstance()->getUserManager().authenticate(username, password, 
			aIsSecure, inactivityMinutes, userSession, aIP);

		if (!session) {
			aRequest.setResponseErrorStr("Invalid username or password");
			return websocketpp::http::status_code::unauthorized;
		}

		json retJson = {
			{ "permissions", session->getUser()->getPermissions() },
			{ "token", session->getAuthToken() },
			{ "user", session->getUser()->getUserName() },
			{ "system", getSystemInfo(aIP) },
			{ "run_wizard", SETTING(WIZARD_RUN) },
			{ "cid", ClientManager::getInstance()->getMyCID().toBase32() },
		};

		if (aSocket) {
			session->onSocketConnected(aSocket);
			aSocket->setSession(session);
		}

		aRequest.setResponseBody(retJson);
		return websocketpp::http::status_code::ok;
	}
开发者ID:airdcpp,项目名称:airdcpp-webapi,代码行数:34,代码来源:SessionApi.cpp

示例5: handleDownload

api_return FilelistApi::handleDownload(ApiRequest& aRequest) {
    const auto& reqJson = aRequest.getRequestBody();
    auto listPath = JsonUtil::getField<string>("list_path", aRequest.getRequestBody(), false);

    string targetDirectory, targetBundleName;
    TargetUtil::TargetType targetType;
    QueueItemBase::Priority prio;
    Deserializer::deserializeDownloadParams(aRequest.getRequestBody(), targetDirectory, targetBundleName, targetType, prio);

    auto user = Deserializer::deserializeHintedUser(reqJson);

    DirectoryListingManager::getInstance()->addDirectoryDownload(Util::toNmdcFile(listPath), targetBundleName, user,
            targetDirectory, targetType, true, prio);

    return websocketpp::http::status_code::ok;
}
开发者ID:fhede,项目名称:airdcpp-webclient,代码行数:16,代码来源:FilelistApi.cpp

示例6: handleSetAway

	api_return SystemApi::handleSetAway(ApiRequest& aRequest) {
		auto away = JsonUtil::getField<bool>("away", aRequest.getRequestBody());
		ActivityManager::getInstance()->setAway(away ? AWAY_MANUAL : AWAY_OFF);

		aRequest.setResponseBody(serializeAwayState());
		return websocketpp::http::status_code::ok;
	}
开发者ID:pavel-pimenov,项目名称:airgit,代码行数:7,代码来源:SystemApi.cpp

示例7: handleRefreshShare

	api_return ShareApi::handleRefreshShare(ApiRequest& aRequest) {
		auto incoming = JsonUtil::getOptionalFieldDefault<bool>("incoming", aRequest.getRequestBody(), false);
		auto ret = ShareManager::getInstance()->refresh(incoming);

		//aRequest.setResponseBody(j);
		return websocketpp::http::status_code::ok;
	}
开发者ID:sbraz,项目名称:airdcpp-webclient,代码行数:7,代码来源:ShareApi.cpp

示例8: handleRefreshPaths

	api_return ShareApi::handleRefreshPaths(ApiRequest& aRequest) {
		auto paths = JsonUtil::getField<StringList>("paths", aRequest.getRequestBody(), false);
		auto ret = ShareManager::getInstance()->refreshPaths(paths);

		//aRequest.setResponseBody(j);
		return websocketpp::http::status_code::ok;
	}
开发者ID:sbraz,项目名称:airdcpp-webclient,代码行数:7,代码来源:ShareApi.cpp

示例9: handleFindDupePaths

	api_return ShareApi::handleFindDupePaths(ApiRequest& aRequest) {
		const auto& reqJson = aRequest.getRequestBody();

		json ret;

		StringList paths;
		auto path = JsonUtil::getOptionalField<string>("path", reqJson, false, false);
		if (path) {
			paths = ShareManager::getInstance()->getDirPaths(Util::toNmdcFile(*path));
		} else {
			auto tth = Deserializer::deserializeTTH(reqJson);
			paths = ShareManager::getInstance()->getRealPaths(tth);
		}

		if (!paths.empty()) {
			for (const auto& p : paths) {
				ret.push_back(p);
			}
		} else {
			ret = json::array();
		}

		aRequest.setResponseBody(ret);
		return websocketpp::http::status_code::ok;
	}
开发者ID:sbraz,项目名称:airdcpp-webclient,代码行数:25,代码来源:ShareApi.cpp

示例10: handleRemoveBundle

api_return QueueApi::handleRemoveBundle(ApiRequest& aRequest) {
    auto removeFinished = JsonUtil::getOptionalFieldDefault<bool>("remove_finished", aRequest.getRequestBody(), false);

    auto b = getBundle(aRequest);
    QueueManager::getInstance()->removeBundle(b, removeFinished);
    return websocketpp::http::status_code::ok;
}
开发者ID:fhede,项目名称:airdcpp-webclient,代码行数:7,代码来源:QueueApi.cpp

示例11: handleUpdateDirectory

	api_return FavoriteDirectoryApi::handleUpdateDirectory(ApiRequest& aRequest) {
		auto path = getPath(aRequest);


		auto info = updatePath(path, aRequest.getRequestBody());
		aRequest.setResponseBody(serializeDirectory(info));
		return websocketpp::http::status_code::ok;
	}
开发者ID:pavel-pimenov,项目名称:airgit,代码行数:8,代码来源:FavoriteDirectoryApi.cpp

示例12: handleResetSettings

	api_return SettingApi::handleResetSettings(ApiRequest& aRequest) {
		const auto& requestJson = aRequest.getRequestBody();

		parseSettingKeys(requestJson, [&](const ApiSettingItem* aItem) {
			aItem->unset();
		});

		return websocketpp::http::status_code::no_content;
	}
开发者ID:sbraz,项目名称:airdcpp-webclient,代码行数:9,代码来源:SettingApi.cpp

示例13: handleAddProfile

	api_return ShareProfileApi::handleAddProfile(ApiRequest& aRequest) {
		const auto& reqJson = aRequest.getRequestBody();

		auto profile = make_shared<ShareProfile>();
		parseProfile(profile, reqJson);

		ShareManager::getInstance()->addProfile(profile);
		return websocketpp::http::status_code::ok;
	}
开发者ID:sbraz,项目名称:airdcpp-webclient,代码行数:9,代码来源:ShareProfileApi.cpp

示例14: handleRemoveSource

api_return QueueApi::handleRemoveSource(ApiRequest& aRequest) {
    auto user = Deserializer::deserializeUser(aRequest.getRequestBody());

    auto removed = QueueManager::getInstance()->removeSource(user, QueueItem::Source::FLAG_REMOVED);
    aRequest.setResponseBody({
        { "count", removed }
    });

    return websocketpp::http::status_code::ok;
}
开发者ID:fhede,项目名称:airdcpp-webclient,代码行数:10,代码来源:QueueApi.cpp

示例15: handleOptimize

	api_return HashApi::handleOptimize(ApiRequest& aRequest) {
		if (HashManager::getInstance()->maintenanceRunning()) {
			aRequest.setResponseErrorStr("Database maintenance is running already");
			return websocketpp::http::status_code::bad_request;
		}

		auto verify = JsonUtil::getField<bool>("verify", aRequest.getRequestBody());
		HashManager::getInstance()->startMaintenance(verify);
		return websocketpp::http::status_code::ok;
	}
开发者ID:airdcpp,项目名称:airdcpp-webapi,代码行数:10,代码来源:HashApi.cpp


注:本文中的ApiRequest::getRequestBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。