10 #ifndef __PION_WEBSERVICE_HEADER__
11 #define __PION_WEBSERVICE_HEADER__
13 #include <boost/noncopyable.hpp>
14 #include <pion/PionConfig.hpp>
15 #include <pion/PionException.hpp>
16 #include <pion/PionAlgorithms.hpp>
17 #include <pion/net/HTTPRequest.hpp>
18 #include <pion/net/TCPConnection.hpp>
29 private boost::noncopyable
37 :
PionException(
"Option not recognized by web service: ", name) {}
52 virtual void operator()(HTTPRequestPtr& request, TCPConnectionPtr& tcp_conn) = 0;
60 virtual void setOption(
const std::string& name,
const std::string& value) {
71 inline void setResource(
const std::string& str) { m_resource = str; }
74 inline const std::string&
getResource(
void)
const {
return m_resource; }
78 if (resource_requested.size() <=
getResource().size()) {
91 std::string m_resource;
std::string getRelativeResource(const std::string &resource_requested) const
returns the path to the resource requested, relative to the web service's location ...
virtual void start(void)
called when the web service's server is starting
WebService(void)
default constructor
const std::string & getResource(void) const
returns the URI stem or resource that is bound to the web service
virtual void stop(void)
called when the web service's server is stopping
void setResource(const std::string &str)
sets the URI stem or resource that is bound to the web service
static std::string url_decode(const std::string &str)
escapes URL-encoded strings (a%20value+with%20spaces)
exception thrown if the service does not recognize a configuration option
virtual ~WebService()
virtual destructor
virtual void setOption(const std::string &name, const std::string &value)
virtual void operator()(HTTPRequestPtr &request, TCPConnectionPtr &tcp_conn)=0