## Class basic_webapp

zeep::http::basic_webapp

## Synopsis

    // In header: </build/libzeep-8SPbhu/libzeep-3.0.5/zeep/http/webapp.hpp>

    class basic_webapp {
    public:
      // member classes/structs/unions

      struct mount_point {

        // public data members
        std::string path;
        std::string realm;
        handler_type handler;
      };
      // construct/copy/destruct
      basic_webapp(const std::string & = "http://www.cmbi.ru.nl/libzeep/ml",
                   const boost::filesystem::path & = ".");
      ~basic_webapp();

      // public member functions
      virtual void set_docroot(const boost::filesystem::path &);
      boost::filesystem::path get_docroot() const;
      virtual void validate_authentication(request &, const std::string &);
      virtual std::string
      validate_authentication(const std::string &, const std::string &,
                              const std::string &, const std::string &);
      virtual std::string
      get_hashed_password(const std::string &, const std::string &);
      virtual void
      create_unauth_reply(const request &, bool, const std::string &,
                          const std::string &, reply &);
      virtual void create_error_reply(const request &, status_type, reply &);
      virtual void
      create_error_reply(const request &, status_type, const std::string &,
                         reply &);
      virtual void handle_request(const request &, reply &);

      // protected member functions
      virtual void
      create_unauth_reply(const request &, bool, const std::string &, reply &);
      void mount(const std::string &, handler_type);
      void mount(const std::string &, const std::string &, handler_type);
      virtual void handle_file(const request &, const el::scope &, reply &);
      virtual void load_template(const std::string &, xml::document &);
      void load_template(const boost::filesystem::path &, xml::document &);
      virtual void get_cookies(const el::scope &, parameter_map &);
      virtual void
      create_reply_from_template(const std::string &, const el::scope &, reply &);
      virtual void
      process_xml(xml::node *, const el::scope &, boost::filesystem::path);
      virtual void add_processor(const std::string &, processor_type);
      virtual void
      process_include(xml::element *, const el::scope &, boost::filesystem::path);
      virtual void
      process_if(xml::element *, const el::scope &, boost::filesystem::path);
      virtual void
      process_iterate(xml::element *, const el::scope &, boost::filesystem::path);
      virtual void
      process_for(xml::element *, const el::scope &, boost::filesystem::path);
      virtual void
      process_number(xml::element *, const el::scope &, boost::filesystem::path);
      virtual void
      process_options(xml::element *, const el::scope &, boost::filesystem::path);
      virtual void
      process_option(xml::element *, const el::scope &, boost::filesystem::path);
      virtual void
      process_checkbox(xml::element *, const el::scope &, boost::filesystem::path);
      virtual void
      process_url(xml::element *, const el::scope &, boost::filesystem::path);
      virtual void
      process_param(xml::element *, const el::scope &, boost::filesystem::path);
      virtual void
      process_embed(xml::element *, const el::scope &, boost::filesystem::path);
      virtual void init_scope(el::scope &);
      virtual void get_parameters(const el::scope &, parameter_map &);
    };

## Description

### `basic_webapp` public construct/copy/destruct

1.     basic_webapp(const std::string & ns = "http://www.cmbi.ru.nl/libzeep/ml",
                    const boost::filesystem::path & docroot = ".");

   first parameter to constructor is the namespace to use in template XHTML files.

2.     ~basic_webapp();

### `basic_webapp` public member functions

1.     virtual void set_docroot(const boost::filesystem::path & docroot);

2.     boost::filesystem::path get_docroot() const;

3.     virtual void
       validate_authentication(request & request, const std::string & realm);

   Support for HTTP Authentication, sets the username field in the request.

4.     virtual std::string
       validate_authentication(const std::string & authorization,
                               const std::string & method, const std::string & uri,
                               const std::string & realm);

   Support for HTTP Authentication, returns the validated user name.

5.     virtual std::string
       get_hashed_password(const std::string & username, const std::string & realm);

   Subclasses should implement this to return the password for the user, result should be the MD5 hash of the string username + ':' + realm + ':' + password

6.     virtual void
       create_unauth_reply(const request & req, bool stale,
                           const std::string & realm,
                           const std::string & authentication, reply & rep);

   Create an error reply for the error containing a validation header.

7.     virtual void
       create_error_reply(const request & req, status_type status, reply & rep);

   Create an error reply for the error.

8.     virtual void
       create_error_reply(const request & req, status_type status,
                          const std::string & message, reply & rep);

   Create an error reply for the error with an additional message for the user.

9.     virtual void handle_request(const request & req, reply & rep);

   Dispatch and handle the request.

### `basic_webapp` protected member functions

1.     virtual void
       create_unauth_reply(const request & req, bool stale,
                           const std::string & realm, reply & rep);

2.     void mount(const std::string & path, handler_type handler);

   assign a handler function to a path in the server's namespace Usually called like this:

   mount("page", boost::bind(&page_handler, this, _1, _2, _3));

   Where page_handler is defined as:

   void my_server::page_handler(const request& request, const el::scope& scope, reply& reply);

3.     void mount(const std::string & path, const std::string & realm,
                  handler_type handler);

   version of mount that requires authentication

4.     virtual void
       handle_file(const request & request, const el::scope & scope, reply & reply);

   Default handler for serving files out of our doc root.

5.     virtual void load_template(const std::string & file, xml::document & doc);

   Use load_template to fetch the XHTML template file.

6.     void load_template(const boost::filesystem::path & file, xml::document & doc);

7.     virtual void get_cookies(const el::scope & scope, parameter_map & cookies);

   Return a `parameter_map` containing the cookies as found in the current request.

8.     virtual void
       create_reply_from_template(const std::string & file, const el::scope & scope,
                                  reply & reply);

   create a reply based on a template

9.     virtual void
       process_xml(xml::node * node, const el::scope & scope,
                   boost::filesystem::path dir);

   process xml parses the XHTML and fills in the special tags and evaluates the el constructs

10.     virtual void add_processor(const std::string & name, processor_type processor);

    To add additional processors.

11.     virtual void
        process_include(xml::element * node, const el::scope & scope,
                        boost::filesystem::path dir);

    default handler for mrs:include tags

12.     virtual void
        process_if(xml::element * node, const el::scope & scope,
                   boost::filesystem::path dir);

    default handler for mrs:if tags

13.     virtual void
        process_iterate(xml::element * node, const el::scope & scope,
                        boost::filesystem::path dir);

    default handler for mrs:iterate tags

14.     virtual void
        process_for(xml::element * node, const el::scope & scope,
                    boost::filesystem::path dir);

    default handler for mrs:for tags

15.     virtual void
        process_number(xml::element * node, const el::scope & scope,
                       boost::filesystem::path dir);

    default handler for mrs:number tags

16.     virtual void
        process_options(xml::element * node, const el::scope & scope,
                        boost::filesystem::path dir);

    default handler for mrs:options tags

17.     virtual void
        process_option(xml::element * node, const el::scope & scope,
                       boost::filesystem::path dir);

    default handler for mrs:option tags

18.     virtual void
        process_checkbox(xml::element * node, const el::scope & scope,
                         boost::filesystem::path dir);

    default handler for mrs:checkbox tags

19.     virtual void
        process_url(xml::element * node, const el::scope & scope,
                    boost::filesystem::path dir);

    default handler for mrs:url tags

20.     virtual void
        process_param(xml::element * node, const el::scope & scope,
                      boost::filesystem::path dir);

    default handler for mrs:param tags

21.     virtual void
        process_embed(xml::element * node, const el::scope & scope,
                      boost::filesystem::path dir);

    default handler for mrs:embed tags

22.     virtual void init_scope(el::scope & scope);

    Initialize the `el::scope` object.

23.     virtual void
        get_parameters(const el::scope & scope, parameter_map & parameters);

    Return the original parameters as found in the current request.