## Class basic_server

zeep::http::basic_server — The libzeep HTTP server implementation. Originally based on example code found in boost::asio.

## Synopsis

    // In header: <zeep/http/server.hpp>

    class basic_server {
    public:
      // construct/copy/destruct
      ();
      ();
      (security_context *);
      (security_context *, );
      (basic_server &) = ;
      basic_server & (basic_server &) = ;
      ~();

      // public member functions
      security_context & ();
       () ;
       ();
       () ;
       ();
       () ;
       (controller *);
       (error_handler *);
       (basic_template_processor *);
      basic_template_processor & ();
      basic_template_processor & () ;
       () ;
       (, );
       ();
       ();
       ();
       () ;
       () ;
       () = ;
       ();

      // public static functions
       ();

      // protected member functions

      (, request &, reply &,
                  , ,
                  , ) ;

      // private member functions

      (, request &, reply &);
       ();
    };

## Description

The server class is a simple, stand alone HTTP server. Call bind to make it listen to an address/port combination. Add controller classes to do the actual work. These controllers will be tried in the order at which they were added to see if they want to process a request.

### `basic_server` public construct/copy/destruct

1.     ();

   Simple server, no security, no template processor.

2.     ( docroot);

   Simple server, no security, create default template processor with docroot.

3.     (security_context * s_ctxt);

   server with a security context for limited access

4.     (security_context * s_ctxt,  docroot);

   server with a security context for limited access, create default template processor with docroot

5.     (basic_server &) = ;

6.     basic_server & (basic_server &) = ;

7.     ~();

### `basic_server` public member functions

1.     security_context & ();

   Get the security context provided in the constructor.

2.      () ;

   Test if a security context was provided in the constructor.

3.      ( methods);

   Set the set of allowed methods (default is "GET", "POST", "PUT", "OPTIONS", "HEAD", "DELETE")

4.      () ;

   Get the set of allowed methods.

5.      ( context_name);

   Set the context_name.

   The context name is used in constructing relative URL's that start with a forward slash

6.      () ;

   Get the context_name.

   The context name is used in constructing relative URL's that start with a forward slash

7.      (controller * c);

   Add controller to the list of controllers.

   When a request is received, the list of controllers get a chance of handling it, in the order of which they were added to this server. If none of the controller handle the request the not_found error is returned.

8.      (error_handler * eh);

   Add an error handler.

   Errors are handled by the error handler list. The last added handler is called first.

9.      (basic_template_processor * template_processor);

   Set the template processor.

   A template processor handles loading templates and processing the contents.

10.     basic_template_processor & ();

    Get the template processor.

    A template processor handles loading templates and processing the contents. This will throw if the processor has not been set yet.

11.     basic_template_processor & () ;

    Get the template processor.

    A template processor handles loading templates and processing the contents. This will throw if the processor has not been set yet.

12.      () ;

    returns whether template processor has been set

13.      ( address,  port);

    Bind the server to address address and port port.

14.      ( nr_of_threads);

    Run as many as nr_of_threads threads simultaneously.

15.      ();

    Stop all threads and stop listening.

16.      ( v);

    log_forwarded tells the HTTP server to use the last entry in X-Forwarded-For as client log entry

17.      () ;

    returns the address as specified in bind

18.      () ;

    returns the port as specified in bind

19.      () = ;

    get_io_context has to be public since we need it to call notify_fork from child code

20.      ();

    get_executor has to be public since we need it to call notify_fork from child code

### `basic_server` public static functions

1.      ();

   to extend the log entry for a current request, use this ostream:

### `basic_server` protected member functions

1.     ( client, request & req,
                   reply & rep,  start,
                    referer,  userAgent,
                    entry) ;

   the default entry logger

### `basic_server` private member functions

1.     ( socket, request & req,
                      reply & rep);

2.      ( ec);