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


C++ Response::c_handler方法代码示例

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


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

示例1: render_to_response

onion_connection_status Onion::render_to_response(::Onion::template_f fn, const ::Onion::Dict& context, ::Onion::Response &res) {
    ONION_DEBUG("Context: %s", context.toJSON().c_str());

    onion_dict *d=onion_dict_dup( context.c_handler() );

    fn(d, res.c_handler());

    return OCS_PROCESSED;
}
开发者ID:hchtym,项目名称:onion,代码行数:9,代码来源:shortcuts.cpp

示例2: getSettingKinectWrapped

/* Like 'search_file' */
onion_connection_status OnionServer::getSettingKinectWrapped(
		Onion::Request &req, Onion::Response &res)
{
	const char* path = onion_request_get_fullpath( req.c_handler() );
#ifdef VERBOSE
	printf("Request of %s.\n",path);
#endif
	std::string filename("./html/");
	filename.append(path);

	std::ifstream file(filename.c_str());
	std::string line;

	if( file.is_open()){

		/* Create header with mime type and charset information for several file extensions.
		 * This is just a workaround. There should be an automatic mechanicm
		 * in libonion. */
		int periodPos = filename.find_last_of('.');
		std::string extension = filename.substr(periodPos+1);
		std::string key("Content-Type");
		std::string defaultType("text/html; charset: utf-8");

		std::string mime = m_mimedict.get( extension , defaultType ) ;
		res.setHeader(key,mime);
		onion_response_write_headers(res.c_handler());// missing in cpp bindings?
		//res.writeHeaders();//this was added by me...

		try{
			/*
			res.write("json_kinect = ", 14);
			const char* kinect = m_settingKinect.getConfig(true);
			size_t len = strlen( kinect );
			res.write(kinect, (int) len );
			res.write(";\n", 2 );
			*/

			while (std::getline(file, line)) {
				res.write( line.c_str(), line.size() );
				res.write("\n", 1 );
			}
		}//catch ( const boost::iobase::failure &ex )
		catch ( const std::exception & ex ){
			std::cerr << "Can not read " << filename << std::endl;
			res.write( ErrReadFailed.c_str(), ErrReadFailed.size());
		}
	}else{
		res.write( ErrNotFound.c_str(), ErrNotFound.size());
	}

	return OCS_PROCESSED;
}
开发者ID:YggdrasiI,项目名称:KinectGrid,代码行数:53,代码来源:OnionServer.cpp

示例3: key

/*
 Replace some template variables and send b9creator_settings.js
*/
onion_connection_status OnionServer::getB9CreatorSettingsWrapped(
		Onion::Request &req, Onion::Response &res)
{
	/*
		 std::string key("ONION_JSON");
		 std::string conf(m_b9CreatorSettings.getConfig());
		 Onion::Dict d;
		 d.add(key, conf, 0);
		 return b9creator_settings_js_template(d.c_handler(), req.c_handler(), res.c_handler());
		 */
	onion_dict *d=onion_dict_new();//will free'd in template call
	onion_dict_add( d, "ONION_JSON",
			m_b9CreatorSettings.getConfig(), 0);
	return b9creator_settings_js_template(d, req.c_handler(), res.c_handler());
}
开发者ID:SHINOTECH,项目名称:TinyPrint,代码行数:18,代码来源:OnionServer.cpp

示例4: index_html

/*
 Replace some template variables (filename of last config) call index_html_template
*/
onion_connection_status OnionServer::index_html( Onion::Request &req, Onion::Response &res)
{
	/* Problem: This cause double free of mem because
	 * onion_dict_free will called twice: in index_html_template and deconstructor.
	 * Onion::Dict d;
	 std::string key("LAST_SETTING_FILENAME");
	 d.add(key,m_b9CreatorSettings.m_configFilename,0);
	 return index_html_template(d.c_handler(), req.c_handler(), res.c_handler() );
	 */
	onion_dict *d=onion_dict_new();//will free'd in template call
	onion_dict_add( d, "LAST_SETTING_FILENAME",
			m_b9CreatorSettings.m_configFilename.c_str(), 0);

	return index_html_template(d, req.c_handler(), res.c_handler() );
}
开发者ID:SHINOTECH,项目名称:TinyPrint,代码行数:18,代码来源:OnionServer.cpp

示例5: index_html

/*
 Replace some template variables (filename of last config) call index_html_template
*/
onion_connection_status OnionServer::index_html( Onion::Request &req, Onion::Response &res)
{
	/* Issue note: The following cause double free of mem because
	 * onion_dict_free will called twice: in index_html_template and deconstructor.
	 * Onion::Dict d;
	 std::string key("LAST_SETTING_FILENAME");
	 d.add(key,m_settingKinect.m_configFilename,0);
	 return index_html_template(d.c_handler(), req.c_handler(), res.c_handler() );

	 => Thus, use pointer, but do not free here.
	 */
	onion_dict *d=onion_dict_new();//will free'd in template call
	onion_dict_add( d, "LAST_SETTING_FILENAME",
			m_settingKinect.m_configFilename.c_str(), 0);

	return index_html_template(d, req.c_handler(), res.c_handler() );
}
开发者ID:YggdrasiI,项目名称:KinectGrid,代码行数:20,代码来源:OnionServer.cpp

示例6: redirect

onion_connection_status Onion::redirect(const std::string& url, ::Onion::Request& req, ::Onion::Response& res)
{
    return onion_shortcut_redirect(url.c_str(), req.c_handler(), res.c_handler());
}
开发者ID:hchtym,项目名称:onion,代码行数:4,代码来源:shortcuts.cpp

示例7: extended_html_template

onion_connection_status extended_html_template(Onion::Request &req, Onion::Response &res){
	extended_html_template(NULL,req.c_handler(), res.c_handler());
}
开发者ID:davidmoreno,项目名称:onion,代码行数:3,代码来源:02-test.cpp


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