17 #ifndef COM_BORA_SOFTWARE__BALAU_NETWORK_HTTP_SERVER_HTTP_WEB_APPS__REDIRECTING_HTTP_WEB_APP 18 #define COM_BORA_SOFTWARE__BALAU_NETWORK_HTTP_SERVER_HTTP_WEB_APPS__REDIRECTING_HTTP_WEB_APP 25 class EnvironmentProperties;
27 namespace Network::Http::HttpWebApps {
54 std::map<std::string, std::string> & variables)
override;
58 std::map<std::string, std::string> & variables)
override;
62 std::map<std::string, std::string> & variables)
override;
68 std::map<std::string, std::string> & variables);
70 public:
struct PathComponent {
75 void append(std::ostringstream & stream, std::map<std::string, std::string> & variables)
const {
77 auto iter = variables.find(value);
79 if (iter != variables.end()) {
80 stream << iter->second;
88 public:
struct Redirection {
91 std::vector<PathComponent> pathComponents;
96 std::string createPath(std::map<std::string, std::string> & variables)
const {
97 std::ostringstream stream;
99 for (
auto & component : pathComponents) {
100 component.append(stream, variables);
106 Redirection() =
default;
107 Redirection(
const Redirection & ) =
default;
108 Redirection & operator = (
const Redirection & ) =
default;
110 Redirection(
const std::regex & matcher_,
112 const std::vector<PathComponent> & pathComponents_
114 ,
const std::string regexStr_
119 , pathComponents(pathComponents_)
121 , regexStr(regexStr_)
126 private:
static std::vector<Redirection> buildRedirections(
const EnvironmentProperties & configuration,
127 const BalauLogger & logger);
129 private:
static std::vector<PathComponent> buildPathComponents(
const std::string & path);
131 private:
const std::vector<Redirection> redirections;
138 #endif // COM_BORA_SOFTWARE__BALAU_NETWORK_HTTP_SERVER_HTTP_WEB_APPS__REDIRECTING_HTTP_WEB_APP Manages the handling of HTTP messages and WebSocket upgrade requests in an HTTP connection.
Definition: HttpSession.hpp:46
void handlePostRequest(HttpSession &session, const StringRequest &request, std::map< std::string, std::string > &variables) override
Handle a POST request.
The root Balau namespace.
Definition: ApplicationConfiguration.hpp:23
A hierarchical environment properties holder created from a composite property.
Definition: EnvironmentProperties.hpp:59
Abstract base class of HTTP web application handlers.
Definition: HttpWebApp.hpp:39
void handleGetRequest(HttpSession &session, const StringRequest &request, std::map< std::string, std::string > &variables) override
Handle a GET request.
void handleHeadRequest(HttpSession &session, const StringRequest &request, std::map< std::string, std::string > &variables) override
Handle a HEAD request.
Abstract base class of HTTP web application handlers.
RedirectingHttpWebApp(const EnvironmentProperties &configuration, const BalauLogger &logger)
Constructor called by the HTTP server during construction.
Request< StringBody > StringRequest
A request with a string body.
Definition: NetworkTypes.hpp:267
An HTTP web application handler that performs 301 or 302 redirection for a range of HTTP paths...
Definition: RedirectingHttpWebApp.hpp:44