00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __PION_PLUGIN_SERVICE_HEADER__
00011 #define __PION_PLUGIN_SERVICE_HEADER__
00012
00013 #include <string>
00014 #include <boost/noncopyable.hpp>
00015 #include <pion/config.hpp>
00016 #include <pion/error.hpp>
00017 #include <pion/algorithm.hpp>
00018 #include <pion/http/request.hpp>
00019 #include <pion/tcp/connection.hpp>
00020
00021
00022 namespace pion {
00023 namespace http {
00024
00025
00029 class plugin_service :
00030 private boost::noncopyable
00031 {
00032 public:
00033
00035 plugin_service(void) {}
00036
00038 virtual ~plugin_service() {}
00039
00046 virtual void operator()(http::request_ptr& http_request_ptr, tcp::connection_ptr& tcp_conn) = 0;
00047
00054 virtual void set_option(const std::string& name, const std::string& value) {
00055 BOOST_THROW_EXCEPTION( error::bad_arg() << error::errinfo_arg_name(name) );
00056 }
00057
00059 virtual void start(void) {}
00060
00062 virtual void stop(void) {}
00063
00065 inline void set_resource(const std::string& str) { m_resource = str; }
00066
00068 inline const std::string& get_resource(void) const { return m_resource; }
00069
00071 inline std::string get_relative_resource(const std::string& resource_requested) const {
00072 if (resource_requested.size() <= get_resource().size()) {
00073
00074
00075 return std::string();
00076 }
00077
00078 return algorithm::url_decode(resource_requested.substr(get_resource().size() + 1));
00079 }
00080
00081
00082 private:
00083
00085 std::string m_resource;
00086 };
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 }
00115 }
00116
00117 #endif