CannedHttpWebApp.hpp
Go to the documentation of this file.
1 // @formatter:off
2 //
3 // Balau core C++ library
4 //
5 // Copyright (C) 2017 Bora Software (contact@borasoftware.com)
6 //
7 // Licensed under the Boost Software License - Version 1.0 - August 17th, 2003.
8 // See the LICENSE file for the full license text.
9 //
10 
16 
17 #ifndef COM_BORA_SOFTWARE__BALAU_NETWORK_HTTP_SERVER_HTTP_WEB_APPS__CANNED_HTTP_WEB_APP
18 #define COM_BORA_SOFTWARE__BALAU_NETWORK_HTTP_SERVER_HTTP_WEB_APPS__CANNED_HTTP_WEB_APP
19 
21 
22 namespace Balau {
23 
24 class BalauLogger;
25 class EnvironmentProperties;
26 
27 namespace Network::Http::HttpWebApps {
28 
32 class CannedHttpWebApp : public HttpWebApp {
45  public: CannedHttpWebApp(std::string mimeType_, std::string getResponseBody_, std::string postResponseBody_);
46 
50  public: CannedHttpWebApp(const EnvironmentProperties & configuration, const BalauLogger & logger);
51 
52  public: void handleGetRequest(HttpSession & session,
53  const StringRequest & request,
54  std::map<std::string, std::string> & variables) override;
55 
56  public: void handleHeadRequest(HttpSession & session,
57  const StringRequest & request,
58  std::map<std::string, std::string> & variables) override;
59 
60  public: void handlePostRequest(HttpSession & session,
61  const StringRequest & request,
62  std::map<std::string, std::string> & variables) override;
63 
65 
66  private: void handle(HttpSession & session, const StringRequest & request, const std::string & body);
67 
68  private: const std::string mimeType;
69  private: const std::string getResponseBody;
70  private: const std::string postResponseBody;
71 };
72 
73 } // namespace Network::Http::HttpWebApps
74 
75 } // namespace Balau
76 
77 #endif // COM_BORA_SOFTWARE__BALAU_NETWORK_HTTP_SERVER_HTTP_WEB_APPS__CANNED_HTTP_WEB_APP
void handleHeadRequest(HttpSession &session, const StringRequest &request, std::map< std::string, std::string > &variables) override
Handle a HEAD request.
Manages the handling of HTTP messages and WebSocket upgrade requests in an HTTP connection.
Definition: HttpSession.hpp:46
The root Balau namespace.
Definition: ApplicationConfiguration.hpp:23
A hierarchical environment properties holder created from a composite property.
Definition: EnvironmentProperties.hpp:59
An HTTP web application handler that serves a fixed response for each request method.
Definition: CannedHttpWebApp.hpp:32
Abstract base class of HTTP web application handlers.
Definition: HttpWebApp.hpp:39
Abstract base class of HTTP web application handlers.
void handleGetRequest(HttpSession &session, const StringRequest &request, std::map< std::string, std::string > &variables) override
Handle a GET request.
Request< StringBody > StringRequest
A request with a string body.
Definition: NetworkTypes.hpp:267
CannedHttpWebApp(std::string mimeType_, std::string getResponseBody_, std::string postResponseBody_)
Create a canned handler that has get and post method bodies.
void handlePostRequest(HttpSession &session, const StringRequest &request, std::map< std::string, std::string > &variables) override
Handle a POST request.