Electroneum
epee::http_server_impl_base< t_child_class, t_connection_context > Class Template Reference

#include <http_server_impl_base.h>

Inheritance diagram for epee::http_server_impl_base< t_child_class, t_connection_context >:
Collaboration diagram for epee::http_server_impl_base< t_child_class, t_connection_context >:

Public Member Functions

 http_server_impl_base ()
 
 http_server_impl_base (boost::asio::io_service &external_io_service)
 
bool init (std::function< void(size_t, uint8_t *)> rng, const std::string &bind_port="0", const std::string &bind_ip="0.0.0.0", std::vector< std::string > access_control_origins=std::vector< std::string >(), boost::optional< net_utils::http::login > user=boost::none, net_utils::ssl_options_t ssl_options=net_utils::ssl_support_t::e_ssl_support_autodetect)
 
bool run (size_t threads_count, bool wait=true)
 
bool deinit ()
 
bool timed_wait_server_stop (uint64_t ms)
 
bool send_stop_signal ()
 
int get_binded_port ()
 
long get_connections_count () const
 
- Public Member Functions inherited from epee::net_utils::http::i_http_server_handler< t_connection_context >
virtual ~i_http_server_handler ()
 
virtual bool handle_http_request (const http_request_info &query_info, http_response_info &response, t_connection_context &m_conn_context)=0
 
virtual bool init_server_thread ()
 
virtual bool deinit_server_thread ()
 

Protected Attributes

net_utils::boosted_tcp_server< net_utils::http::http_custom_handler< t_connection_context > > m_net_server
 

Detailed Description

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
class epee::http_server_impl_base< t_child_class, t_connection_context >

Definition at line 47 of file http_server_impl_base.h.

Constructor & Destructor Documentation

◆ http_server_impl_base() [1/2]

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
epee::http_server_impl_base< t_child_class, t_connection_context >::http_server_impl_base ( )
inline

Definition at line 51 of file http_server_impl_base.h.

53  {}
net_utils::boosted_tcp_server< net_utils::http::http_custom_handler< t_connection_context > > m_net_server

◆ http_server_impl_base() [2/2]

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
epee::http_server_impl_base< t_child_class, t_connection_context >::http_server_impl_base ( boost::asio::io_service &  external_io_service)
inlineexplicit

Definition at line 55 of file http_server_impl_base.h.

56  : m_net_server(external_io_service)
57  {}
net_utils::boosted_tcp_server< net_utils::http::http_custom_handler< t_connection_context > > m_net_server

Member Function Documentation

◆ deinit()

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
bool epee::http_server_impl_base< t_child_class, t_connection_context >::deinit ( )
inline

Definition at line 102 of file http_server_impl_base.h.

103  {
104  return m_net_server.deinit_server();
105  }
net_utils::boosted_tcp_server< net_utils::http::http_custom_handler< t_connection_context > > m_net_server
Here is the caller graph for this function:

◆ get_binded_port()

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
int epee::http_server_impl_base< t_child_class, t_connection_context >::get_binded_port ( )
inline

Definition at line 118 of file http_server_impl_base.h.

119  {
120  return m_net_server.get_binded_port();
121  }
net_utils::boosted_tcp_server< net_utils::http::http_custom_handler< t_connection_context > > m_net_server

◆ get_connections_count()

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
long epee::http_server_impl_base< t_child_class, t_connection_context >::get_connections_count ( ) const
inline

Definition at line 123 of file http_server_impl_base.h.

124  {
125  return m_net_server.get_connections_count();
126  }
net_utils::boosted_tcp_server< net_utils::http::http_custom_handler< t_connection_context > > m_net_server

◆ init()

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
bool epee::http_server_impl_base< t_child_class, t_connection_context >::init ( std::function< void(size_t, uint8_t *)>  rng,
const std::string &  bind_port = "0",
const std::string &  bind_ip = "0.0.0.0",
std::vector< std::string >  access_control_origins = std::vector<std::string>(),
boost::optional< net_utils::http::login user = boost::none,
net_utils::ssl_options_t  ssl_options = net_utils::ssl_support_t::e_ssl_support_autodetect 
)
inline

Definition at line 59 of file http_server_impl_base.h.

63  {
64 
65  //set self as callback handler
66  m_net_server.get_config_object().m_phandler = static_cast<t_child_class*>(this);
67  m_net_server.get_config_object().rng = std::move(rng);
68 
69  //here set folder for hosting reqests
70  m_net_server.get_config_object().m_folder = "";
71 
72  //set access control allow origins if configured
73  std::sort(access_control_origins.begin(), access_control_origins.end());
74  m_net_server.get_config_object().m_access_control_origins = std::move(access_control_origins);
75 
76  m_net_server.get_config_object().m_user = std::move(user);
77 
78  MGINFO("Binding on " << bind_ip << ":" << bind_port);
79  bool res = m_net_server.init_server(bind_port, bind_ip, std::move(ssl_options));
80  if(!res)
81  {
82  LOG_ERROR("Failed to bind server");
83  return false;
84  }
85  return true;
86  }
const char * res
Definition: hmac_keccak.cpp:41
net_utils::boosted_tcp_server< net_utils::http::http_custom_handler< t_connection_context > > m_net_server
#define MGINFO(x)
Definition: misc_log_ex.h:80
const T & move(const T &t)
Definition: gtest-port.h:1317
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
Here is the caller graph for this function:

◆ run()

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
bool epee::http_server_impl_base< t_child_class, t_connection_context >::run ( size_t  threads_count,
bool  wait = true 
)
inline

Definition at line 88 of file http_server_impl_base.h.

89  {
90  //go to loop
91  MINFO("Run net_service loop( " << threads_count << " threads)...");
92  if(!m_net_server.run_server(threads_count, wait))
93  {
94  LOG_ERROR("Failed to run net tcp server!");
95  }
96 
97  if(wait)
98  MINFO("net_service loop stopped.");
99  return true;
100  }
net_utils::boosted_tcp_server< net_utils::http::http_custom_handler< t_connection_context > > m_net_server
#define MINFO(x)
Definition: misc_log_ex.h:75
#define LOG_ERROR(x)
Definition: misc_log_ex.h:98
Here is the caller graph for this function:

◆ send_stop_signal()

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
bool epee::http_server_impl_base< t_child_class, t_connection_context >::send_stop_signal ( )
inline

Definition at line 112 of file http_server_impl_base.h.

113  {
114  m_net_server.send_stop_signal();
115  return true;
116  }
net_utils::boosted_tcp_server< net_utils::http::http_custom_handler< t_connection_context > > m_net_server
Here is the caller graph for this function:

◆ timed_wait_server_stop()

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
bool epee::http_server_impl_base< t_child_class, t_connection_context >::timed_wait_server_stop ( uint64_t  ms)
inline

Definition at line 107 of file http_server_impl_base.h.

108  {
109  return m_net_server.timed_wait_server_stop(ms);
110  }
net_utils::boosted_tcp_server< net_utils::http::http_custom_handler< t_connection_context > > m_net_server
Here is the caller graph for this function:

Member Data Documentation

◆ m_net_server

template<class t_child_class, class t_connection_context = epee::net_utils::connection_context_base>
net_utils::boosted_tcp_server<net_utils::http::http_custom_handler<t_connection_context> > epee::http_server_impl_base< t_child_class, t_connection_context >::m_net_server
protected

Definition at line 129 of file http_server_impl_base.h.


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