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


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

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


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

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

示例2: handleUnsubscribe

	api_return ApiModule::handleUnsubscribe(ApiRequest& aRequest) {
		auto subscription = aRequest.getStringParam(0);
		if (subscriptionExists(subscription)) {
			setSubscriptionState(subscription, false);
			return websocketpp::http::status_code::ok;
		}

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

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

示例4: handleDeleteChat

	api_return PrivateChatApi::handleDeleteChat(ApiRequest& aRequest) {
		auto chat = getSubModule(aRequest.getStringParam(0));
		if (!chat) {
			aRequest.setResponseErrorStr("Chat session not found");
			return websocketpp::http::status_code::not_found;
		}

		MessageManager::getInstance()->removeChat(chat->getChat()->getUser());
		return websocketpp::http::status_code::ok;
	}
开发者ID:fhede,项目名称:airdcpp-webclient,代码行数:10,代码来源:PrivateChatApi.cpp

示例5: handleRequest

	api_return ApiModule::handleRequest(ApiRequest& aRequest) {
		// Find section
		auto i = requestHandlers.find(aRequest.getStringParam(0));
		if (i == requestHandlers.end()) {
			aRequest.setResponseErrorStr("Invalid API section");
			return websocketpp::http::status_code::bad_request;
		}

		aRequest.popParam();
		const auto& sectionHandlers = i->second;

		bool hasParamMatch = false; // for better error reporting

		// Match parameters
		auto handler = boost::find_if(sectionHandlers, [&](const RequestHandler& aHandler) {
			// Regular matching
			auto matchesParams = aHandler.matchParams(aRequest.getParameters());
			if (!matchesParams) {
				return false;
			}

			if (aHandler.method == aRequest.getMethod() || aHandler.isModuleHandler()) {
				return true;
			}

			hasParamMatch = true;
			return false;
		});

		if (handler == sectionHandlers.end()) {
			if (hasParamMatch) {
				aRequest.setResponseErrorStr("Method not supported for this command");
			} else {
				aRequest.setResponseErrorStr("Invalid parameters for this API section");
			}

			return websocketpp::http::status_code::bad_request;
		}

		// Check JSON payload
		if (handler->requireJson && !aRequest.hasRequestBody()) {
			aRequest.setResponseErrorStr("JSON body required");
			return websocketpp::http::status_code::bad_request;
		}

		// Check permission
		if (!session->getUser()->hasPermission(handler->access)) {
			aRequest.setResponseErrorStr("Permission denied");
			return websocketpp::http::status_code::forbidden;
		}

		// Exact params could be removed from the request...

		return handler->f(aRequest);
	}
开发者ID:sbraz,项目名称:airdcpp-webclient,代码行数:55,代码来源:ApiModule.cpp

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

示例7: handleSessionRequest

	api_return ApiRouter::handleSessionRequest(ApiRequest& aRequest, bool aIsSecure, const WebSocketPtr& aSocket, const string& aIp) {
		if (aRequest.getApiVersion() != 0) {
			aRequest.setResponseErrorStr("Invalid API version");
			return websocketpp::http::status_code::precondition_failed;
		}

		if (aRequest.getStringParam(0) == "auth") {
			if (aRequest.getMethod() == ApiRequest::METHOD_POST) {
				return sessionApi.handleLogin(aRequest, aIsSecure, aSocket, aIp);
			} else if (aRequest.getMethod() == ApiRequest::METHOD_DELETE) {
				return sessionApi.handleLogout(aRequest);
			}
		} else if (aRequest.getStringParam(0) == "socket") {
			return sessionApi.handleSocketConnect(aRequest, aIsSecure, aSocket);
		} else if (aRequest.getStringParam(0) == "away") {
			return sessionApi.handleAway(aRequest);
		}

		aRequest.setResponseErrorStr("Invalid command");
		return websocketpp::http::status_code::bad_request;
	}
开发者ID:sbraz,项目名称:airdcpp-webclient,代码行数:21,代码来源:ApiRouter.cpp

示例8: handleSubscribe

	api_return ApiModule::handleSubscribe(ApiRequest& aRequest) {
		if (!socket) {
			aRequest.setResponseErrorStr("Socket required");
			return websocketpp::http::status_code::precondition_required;
		}

		const auto& subscription = aRequest.getStringParam(0);
		if (!subscriptionExists(subscription)) {
			aRequest.setResponseErrorStr("No such subscription: " + subscription);
			return websocketpp::http::status_code::not_found;
		}

		setSubscriptionState(subscription, true);
		return websocketpp::http::status_code::ok;
	}
开发者ID:sbraz,项目名称:airdcpp-webclient,代码行数:15,代码来源:ApiModule.cpp

示例9: handleGetText

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

		if (!file->isText()) {
			aRequest.setResponseErrorStr("This method can't be used for non-text files");
			return websocketpp::http::status_code::bad_request;
		}

		string content;
		try {
			File f(file->getPath(), File::READ, File::OPEN);

			auto encoding = Util::emptyString;
			bool nfo = Util::getFileExt(file->getPath()) == ".nfo";
			if (nfo) {
				// Platform-independent encoding conversion function could be added if there is more use for it
#ifdef _WIN32
				encoding = "CP.437";
#else
				encoding = "cp437";
#endif
			}

			content = Text::toUtf8(f.read(), encoding);
		} catch (const FileException& e) {
			aRequest.setResponseErrorStr("Failed to open the file: " + e.getError() + "(" + file->getPath() + ")");
			return websocketpp::http::status_code::internal_server_error;
		}

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

示例10: getUser

	UserPtr UserApi::getUser(ApiRequest& aRequest) {
		return Deserializer::getUser(aRequest.getStringParam(0), true);
	}
开发者ID:airdcpp,项目名称:airdcpp-webapi,代码行数:3,代码来源:UserApi.cpp


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