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


C++ ApiRequest类代码示例

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


在下文中一共展示了ApiRequest类的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: 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

示例3: 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

示例4: 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

示例5: 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

示例6: handleRemoveFile

	api_return QueueApi::handleRemoveFile(ApiRequest& aRequest) {
		if (QueueManager::getInstance()->removeFile(aRequest.getTokenParam(0), false)) {
			aRequest.setResponseErrorStr("File not found");
			return websocketpp::http::status_code::bad_request;
		}

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

示例7: handleGetHubs

	api_return RecentHubApi::handleGetHubs(ApiRequest& aRequest) {
		auto hubs = FavoriteManager::getInstance()->getRecentHubs();

		auto retJson = Serializer::serializeFromPosition(aRequest.getRangeParam(0), aRequest.getRangeParam(1), hubs, serializeHub);
		aRequest.setResponseBody(retJson);

		return websocketpp::http::status_code::ok;
	}
开发者ID:Caraul,项目名称:airgit,代码行数:8,代码来源:RecentHubApi.cpp

示例8: 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

示例9: handleGetBundles

// BUNDLES
api_return QueueApi::handleGetBundles(ApiRequest& aRequest)  {
    int start = aRequest.getRangeParam(0);
    int count = aRequest.getRangeParam(1);

    auto j = Serializer::serializeItemList(start, count, bundlePropertyHandler, QueueUtils::getBundleList());

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

示例10: handleRemoveFile

	api_return ViewFileApi::handleRemoveFile(ApiRequest& aRequest) {
		auto success = ViewFileManager::getInstance()->removeFile(Deserializer::parseTTH(aRequest.getStringParam(0)));
		if (!success) {
			aRequest.setResponseErrorStr("File not found");
			return websocketpp::http::status_code::not_found;
		}

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

示例11: handleGetLog

	api_return LogApi::handleGetLog(ApiRequest& aRequest) {
		auto j = Serializer::serializeFromEnd(
			aRequest.getRangeParam(0),
			LogManager::getInstance()->getCache().getLogMessages(),
			Serializer::serializeLogMessage);

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

示例12: handleRemoveFile

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

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

示例13: handleDeleteList

api_return FilelistApi::handleDeleteList(ApiRequest& aRequest) {
    auto list = getSubModule(aRequest.getStringParam(0));
    if (!list) {
        aRequest.setResponseErrorStr("List not found");
        return websocketpp::http::status_code::not_found;
    }

    DirectoryListingManager::getInstance()->removeList(list->getList()->getUser());
    return websocketpp::http::status_code::ok;
}
开发者ID:fhede,项目名称:airdcpp-webclient,代码行数:10,代码来源:FilelistApi.cpp

示例14: 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

示例15: handleLogout

	api_return SessionApi::handleLogout(ApiRequest& aRequest) {
		if (!aRequest.getSession()) {
			aRequest.setResponseErrorStr("Not authorized");
			return websocketpp::http::status_code::unauthorized;
		}

		WebServerManager::getInstance()->logout(aRequest.getSession()->getId());

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


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