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


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

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


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

示例1: handleGetSessions

	api_return SessionApi::handleGetSessions(ApiRequest& aRequest) {
		auto sessions = session->getServer()->getUserManager().getSessions();

		auto ret = json::array();
		for (const auto& s : sessions) {
			ret.push_back(serializeSession(s));
		}

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

示例2: handleGetStats

	api_return TransferApi::handleGetStats(ApiRequest& aRequest) {
		json j;

		j["session_downloaded"] = Socket::getTotalDown();
		j["session_uploaded"] = Socket::getTotalUp();
		j["start_total_downloaded"] = SETTING(TOTAL_DOWNLOAD) - Socket::getTotalDown();
		j["start_total_uploaded"] = SETTING(TOTAL_UPLOAD) - Socket::getTotalUp();

		aRequest.setResponseBody(j);
		return websocketpp::http::status_code::ok;
	}
开发者ID:jameskumar,项目名称:airgit,代码行数:11,代码来源:TransferApi.cpp

示例3: handleGetFiles

	api_return ViewFileApi::handleGetFiles(ApiRequest& aRequest) {
		auto ret = json::array();

		auto files = ViewFileManager::getInstance()->getFiles();
		for (const auto& file : files | map_values) {
			ret.push_back(serializeFile(file));
		}

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

示例4: handleRemoveBundleSource

	api_return QueueApi::handleRemoveBundleSource(ApiRequest& aRequest) {
		auto b = getBundle(aRequest);
		auto user = Deserializer::getUser(aRequest.getStringParam(2), false);

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

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

示例5: handleGetSettingValues

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

		json retJson;
		parseSettingKeys(requestJson, [&](ApiSettingItem* aItem) {
			retJson[aItem->name] = aItem->valueToJson().first;
		});

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

示例6: handleAddDirectory

	api_return FavoriteDirectoryApi::handleAddDirectory(ApiRequest& aRequest) {
		const auto& reqJson = aRequest.getRequestBody();

		auto path = Util::validatePath(JsonUtil::getField<string>("path", reqJson, false), true);
		if (FavoriteManager::getInstance()->hasFavoriteDir(path)) {
			JsonUtil::throwError("path", JsonUtil::ERROR_EXISTS, "Path exists already");
		}

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

示例7: handleGetSettingInfos

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

		auto forceAutoValues = JsonUtil::getOptionalFieldDefault<bool>("force_auto_values", requestJson, false);

		json retJson;
		parseSettingKeys(requestJson, [&](const ApiSettingItem* aItem) {
			retJson[aItem->name] = aItem->infoToJson(forceAutoValues);
		});

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

示例8: handleGetProfiles

	api_return ShareProfileApi::handleGetProfiles(ApiRequest& aRequest) {
		json j;

		auto profiles = ShareManager::getInstance()->getProfiles();

		// Profiles can't be empty
		for (const auto& p : profiles) {
			j.push_back(serializeShareProfile(p));
		}

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

示例9: handleGetIgnores

	api_return UserApi::handleGetIgnores(ApiRequest& aRequest) {
		auto j = json::array();

		auto users = MessageManager::getInstance()->getIgnoredUsers();
		for (const auto& u : users) {
			j.push_back({
				{ "user", Serializer::serializeUser(u.first) },
				{ "ignored_messages", u.second }
			});
		}

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

示例10: handleSearchBundle

	api_return QueueApi::handleSearchBundle(ApiRequest& aRequest) {
		auto b = getBundle(aRequest);
		auto searches = QueueManager::getInstance()->searchBundleAlternates(b, true);

		if (searches == 0) {
			aRequest.setResponseErrorStr("No files to search for");
			return websocketpp::http::status_code::bad_request;
		}

		aRequest.setResponseBody({
			{ "sent", searches },
		});

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

示例11: handleFindDupePaths

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

		auto ret = json::array();

		auto path = JsonUtil::getOptionalField<string>("path", reqJson, false);
		if (path) {
			ret = QueueManager::getInstance()->getNmdcDirPaths(Util::toNmdcFile(*path));
		} else {
			auto tth = Deserializer::deserializeTTH(reqJson);
			ret = QueueManager::getInstance()->getTargets(tth);
		}

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

示例12: handleSearchHubs

	api_return RecentHubApi::handleSearchHubs(ApiRequest& aRequest) {
		const auto& reqJson = aRequest.getRequestBody();

		auto pattern = JsonUtil::getField<string>("pattern", reqJson);
		auto maxResults = JsonUtil::getField<size_t>("max_results", reqJson);

		auto hubs = FavoriteManager::getInstance()->searchRecentHubs(pattern, maxResults);

		json retJson;
		for (const auto& h : hubs) {
			retJson.push_back(serializeHub(h));
		}

		aRequest.setResponseBody(retJson);
		return websocketpp::http::status_code::ok;
	}
开发者ID:jameskumar,项目名称:airgit,代码行数:16,代码来源:RecentHubApi.cpp

示例13: handleSearchNicks

	api_return HubApi::handleSearchNicks(ApiRequest& aRequest) {
		const auto& reqJson = aRequest.getRequestBody();

		auto pattern = JsonUtil::getField<string>("pattern", reqJson);
		auto maxResults = JsonUtil::getField<size_t>("max_results", reqJson);
		auto ignorePrefixes = JsonUtil::getOptionalFieldDefault<bool>("ignore_prefixes", reqJson, true);

		auto users = ClientManager::getInstance()->searchNicks(pattern, maxResults, ignorePrefixes);

		auto retJson = json::array();
		for (const auto& u : users) {
			retJson.push_back(Serializer::serializeOnlineUser(u));
		}

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

示例14: handleGetBundleSources

	api_return QueueApi::handleGetBundleSources(ApiRequest& aRequest) {
		auto b = getBundle(aRequest);
		auto sources = QueueManager::getInstance()->getBundleSources(b);

		auto ret = json::array();
		for (const auto& s : sources) {
			ret.push_back({
				{ "user", Serializer::serializeHintedUser(s.getUser()) },
				{ "last_speed", s.getUser().user->getSpeed() },
				{ "files", s.files },
				{ "size", s.size },
			});
		}

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

示例15: handleConnect

	api_return HubApi::handleConnect(ApiRequest& aRequest) {
		const auto& reqJson = aRequest.getRequestBody();

		auto address = JsonUtil::getField<string>("hub_url", reqJson, false);

		RecentHubEntryPtr r = new RecentHubEntry(address);
		auto client = ClientManager::getInstance()->createClient(r, SETTING(DEFAULT_SP));
		if (!client) {
			aRequest.setResponseErrorStr("Hub exists");
			return websocketpp::http::status_code::bad_request;
		}

		aRequest.setResponseBody({
			{ "id", client->getClientId() }
		});

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


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