pion
5.0.6
|
00001 // --------------------------------------------------------------------- 00002 // pion: a Boost C++ framework for building lightweight HTTP interfaces 00003 // --------------------------------------------------------------------- 00004 // Copyright (C) 2007-2014 Splunk Inc. (https://github.com/splunk/pion) 00005 // 00006 // Distributed under the Boost Software License, Version 1.0. 00007 // See http://www.boost.org/LICENSE_1_0.txt 00008 // 00009 00010 #include "HelloService.hpp" 00011 #include <pion/http/response_writer.hpp> 00012 00013 using namespace pion; 00014 00015 namespace pion { // begin namespace pion 00016 namespace plugins { // begin namespace plugins 00017 00018 00019 // HelloService member functions 00020 00022 void HelloService::operator()(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn) 00023 { 00024 static const std::string HELLO_HTML = "<html><body>Hello World!</body></html>"; 00025 http::response_writer_ptr writer(http::response_writer::create(tcp_conn, *http_request_ptr, 00026 boost::bind(&tcp::connection::finish, tcp_conn))); 00027 writer->write_no_copy(HELLO_HTML); 00028 writer->write_no_copy(http::types::STRING_CRLF); 00029 writer->write_no_copy(http::types::STRING_CRLF); 00030 writer->send(); 00031 } 00032 00033 00034 } // end namespace plugins 00035 } // end namespace pion 00036 00037 00039 extern "C" PION_PLUGIN pion::plugins::HelloService *pion_create_HelloService(void) 00040 { 00041 return new pion::plugins::HelloService(); 00042 } 00043 00045 extern "C" PION_PLUGIN void pion_destroy_HelloService(pion::plugins::HelloService *service_ptr) 00046 { 00047 delete service_ptr; 00048 }