00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "HelloService.hpp"
00011 #include <pion/http/response_writer.hpp>
00012
00013 using namespace pion;
00014
00015 namespace pion {
00016 namespace plugins {
00017
00018
00019
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 }
00035 }
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 }