Webdar 1.0.0
Web user interface to libdar
responder.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef RESPONDER_HPP
25#define RESPONDER_HPP
26
27#include "my_config.h"
28
29 // C++ system header files
30#include <string>
31#include <vector>
32#include <map>
33
34 // webdar headers
35#include "uri.hpp"
36#include "webdar_tools.hpp"
37#include "exceptions.hpp"
38#include "request.hpp"
39#include "answer.hpp"
40#include "chemin.hpp"
41
44
46{
47public:
48 responder() = default;
49 responder(const responder & ref) = default;
50 responder(responder && ref) noexcept = default;
51 responder & operator = (const responder & ref) = default;
52 responder & operator = (responder && ref) noexcept = default;
53 virtual ~responder() {};
54
56 void set_prefix(const chemin & chem) { prefix = chem; prefix_has_changed(); };
58 const chemin & get_prefix() const { return prefix; };
59
61 virtual answer give_answer(const request & req) = 0;
62
63protected:
65 virtual void prefix_has_changed() {};
66
67private:
68 chemin prefix;
69
70};
71
72
73#endif
class answer provides easy means to set an HTTP answer and means to sent it back to a proto_connexion...
Definition: answer.hpp:49
class chemin definition
Definition: chemin.hpp:51
class holding fields of an HTTP request (method, URI, header, cookies, and so on)
Definition: request.hpp:45
pure virtual class, base class for all classes that can generate an answer to a request
Definition: responder.hpp:46
const chemin & get_prefix() const
get the recorded URI path prefix for body_builder root hierarchy
Definition: responder.hpp:58
virtual void prefix_has_changed()
hook for inherited class, when the body builder object had its prefix changed
Definition: responder.hpp:65
void set_prefix(const chemin &chem)
used for body_builder object for they have a proper prefix in path
Definition: responder.hpp:56
virtual answer give_answer(const request &req)=0
provides a standard mean for inherited class to provide answer to requests