10 #ifndef __PION_WEBSERVER_HEADER__
11 #define __PION_WEBSERVER_HEADER__
14 #include <boost/asio.hpp>
15 #include <boost/bind.hpp>
16 #include <boost/shared_ptr.hpp>
17 #include <pion/PionConfig.hpp>
18 #include <pion/PionException.hpp>
19 #include <pion/PionPlugin.hpp>
20 #include <pion/PluginManager.hpp>
21 #include <pion/net/HTTPServer.hpp>
22 #include <pion/net/WebService.hpp>
41 :
PionException(
"No web services are identified by the resource: ", resource) {}
48 :
PionException(
"Web service configuration file not found: ", file) {}
55 :
PionException(
"Unable to parse configuration file: ", file) {}
62 :
PionException(
"Error in web server authorization config: ", error_msg) {}
70 std::string(
"): ") + file)
86 setLogger(PION_GET_LOGGER(
"pion.net.WebServer"));
94 explicit WebServer(
const boost::asio::ip::tcp::endpoint& endpoint)
97 setLogger(PION_GET_LOGGER(
"pion.net.WebServer"));
109 setLogger(PION_GET_LOGGER(
"pion.net.WebServer"));
121 setLogger(PION_GET_LOGGER(
"pion.net.WebServer"));
130 void addService(
const std::string& resource,
WebService *service_ptr);
139 void loadService(
const std::string& resource,
const std::string& service_name);
148 void setServiceOption(
const std::string& resource,
149 const std::string& name,
const std::string& value);
163 void loadServiceConfig(
const std::string& config_name);
167 if (isListening()) stop();
179 catch (std::exception& e) {
190 catch (std::exception& e) {
205 WebServiceManager m_services;
210 typedef boost::shared_ptr<WebServer> WebServerPtr;
exception used to propagate exceptions thrown by web services
virtual ~WebServer()
default destructor
WebServer(PionScheduler &scheduler, const unsigned int tcp_port=0)
exception thrown if the web service configuration file cannot be found
virtual void start(void)
called when the web service's server is starting
virtual void clear(void)
clears the collection of resources recognized by the HTTP server
virtual void stop(void)
called when the web service's server is stopping
WebServer(const unsigned int tcp_port=0)
WebServer(PionScheduler &scheduler, const boost::asio::ip::tcp::endpoint &endpoint)
exception thrown if there is an error parsing the authorization config
exception thrown if a web service cannot be found
virtual void beforeStarting(void)
called before the TCP server starts listening for new connections
virtual void afterStopping(void)
called after the TCP server has stopped listening for new connections
the following enables use of the lock-free cache
exception thrown if the plug-in file cannot be opened
virtual void clear(void)
clears all the web services that are currently configured
WebServer(const boost::asio::ip::tcp::endpoint &endpoint)