# pion::http::plugin_server Class Reference

`#include <plugin_server.hpp>`

Inherits pion::http::server.

List of all members.

## Public Member Functions

virtual | ~plugin_server ()
| default destructor
| plugin_server (const unsigned int tcp_port=0)
| plugin_server (const boost::asio::ip::tcp::endpoint &endpoint)
| plugin_server (scheduler &sched, const unsigned int tcp_port=0)
| plugin_server (scheduler &sched, const boost::asio::ip::tcp::endpoint &endpoint)
void | add_service (const std::string &resource, http::plugin_service *service_ptr)
void | load_service (const std::string &resource, const std::string &service_name)
void | set_service_option (const std::string &resource, const std::string &name, const std::string &value)
void | load_service_config (const std::string &config_name)
virtual void | clear (void)
| clears all the web services that are currently configured

## Protected Member Functions

virtual void | before_starting (void)
| called before the TCP server starts listening for new connections
virtual void | after_stopping (void)
| called after the TCP server has stopped listening for new connections

## Detailed Description

plugin_server: a server that handles HTTP connections using http::plugin_service plug-ins

Definition at line 31 of file plugin_server.hpp.

## Constructor & Destructor Documentation

pion::http::plugin_server::plugin_server | ( | const unsigned int | tcp_port = `0` | ) | `[inline, explicit]`

creates a new plugin_server object

Parameters:

  | tcp_port | port number used to listen for new connections (IPv4)

Definition at line 45 of file plugin_server.hpp.

pion::http::plugin_server::plugin_server | ( | const boost::asio::ip::tcp::endpoint & | endpoint | ) | `[inline, explicit]`

creates a new plugin_server object

Parameters:

  | endpoint | TCP endpoint used to listen for new connections (see ASIO docs)

Definition at line 56 of file plugin_server.hpp.

pion::http::plugin_server::plugin_server | ( | scheduler & | sched,
|  | const unsigned int | tcp_port = `0` |
| ) |  |  | `[inline, explicit]`

creates a new plugin_server object

Parameters:

  | sched | the scheduler that will be used to manage worker threads
  | tcp_port | port number used to listen for new connections (IPv4)

Definition at line 68 of file plugin_server.hpp.

pion::http::plugin_server::plugin_server | ( | scheduler & | sched,
|  | const boost::asio::ip::tcp::endpoint & | endpoint |
| ) |  |  | `[inline]`

creates a new plugin_server object

Parameters:

  | sched | the scheduler that will be used to manage worker threads
  | endpoint | TCP endpoint used to listen for new connections (see ASIO docs)

Definition at line 80 of file plugin_server.hpp.

## Member Function Documentation

void pion::http::plugin_server::add_service | ( | const std::string & | resource,
|  | http::plugin_service * | service_ptr |
| ) |  |  |

adds a new web service to the web server

Parameters:

  | resource | the resource name or uri-stem to bind to the web service
  | service_ptr | a pointer to the web service

Definition at line 27 of file http_plugin_server.cpp.

References pion::plugin_manager< PluginType >::add(), pion::http::server::add_resource(), pion::tcp::server::m_logger, pion::http::plugin_service::set_resource(), and pion::http::server::strip_trailing_slash().

void pion::http::plugin_server::load_service | ( | const std::string & | resource,
|  | const std::string & | service_name |
| ) |  |  |

loads a web service from a shared object file

Parameters:

  | resource | the resource name or uri-stem to bind to the web service
  | service_name | the name of the web service to load (searches plug-in directories and appends extensions)

Definition at line 37 of file http_plugin_server.cpp.

References pion::http::server::add_resource(), pion::plugin_manager< PluginType >::load(), pion::tcp::server::m_logger, pion::http::plugin_service::set_resource(), and pion::http::server::strip_trailing_slash().

Referenced by load_service_config().

void pion::http::plugin_server::load_service_config | ( | const std::string & | config_name | ) |

Parses a simple web service configuration file. Each line in the file starts with one of the following commands:

path VALUE : adds a directory to the web service search path service RESOURCE FILE : loads web service bound to RESOURCE from FILE option RESOURCE NAME=VALUE : sets web service option NAME to VALUE

Blank lines or lines that begin with # are ignored as comments.

Parameters:

  | config_name | the name of the config file to parse

Definition at line 56 of file http_plugin_server.cpp.

References pion::plugin::add_plugin_directory(), pion::plugin::find_config_file(), load_service(), pion::tcp::server::m_logger, pion::http::server::set_authentication(), and set_service_option().

void pion::http::plugin_server::set_service_option | ( | const std::string & | resource,
|  | const std::string & | name,
|  | const std::string & | value |
| ) |  |  |

sets a configuration option for the web service associated with resource

Parameters:

  | resource | the resource name or uri-stem that identifies the web service
  | name | the name of the configuration option
  | value | the value to set the option to

Definition at line 47 of file http_plugin_server.cpp.

References pion::tcp::server::m_logger, pion::plugin_manager< PluginType >::run(), pion::http::plugin_service::set_option(), and pion::http::server::strip_trailing_slash().

Referenced by load_service_config().

The documentation for this class was generated from the following files:

- include/pion/http/plugin_server.hpp
- src/http_plugin_server.cpp