17 #ifndef COM_BORA_SOFTWARE__BALAU_NETWORK_HTTP_SERVER_HTTP_WEB_APPS__EMAIL_SENDING_HTTP_WEB_APP 18 #define COM_BORA_SOFTWARE__BALAU_NETWORK_HTTP_SERVER_HTTP_WEB_APPS__EMAIL_SENDING_HTTP_WEB_APP 21 #include <Balau/Network/Http/Server/HttpWebApps/Impl/CurlEmailSender.hpp> 24 #pragma clang diagnostic push 25 #pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection" 30 class EnvironmentProperties;
32 namespace Network::Http::HttpWebApps {
56 public:
using ParameterMap = std::unordered_map<std::string, std::string> ;
63 std::map<std::string, std::string> & variables,
76 std::shared_ptr<HttpWebApp> successHandler_,
77 std::shared_ptr<HttpWebApp> failureHandler_,
82 std::string userAgent,
86 std::vector<std::string> cc_ = {},
99 std::string successRedirectLocation_,
100 std::string failureRedirectLocation_,
105 std::string userAgent,
106 std::string subject_,
109 std::vector<std::string> cc_ = {},
110 bool useTLS_ =
true);
121 std::map<std::string, std::string> & variables)
override;
125 std::map<std::string, std::string> & variables)
override;
129 std::map<std::string, std::string> & variables)
override;
133 private:
static unsigned short verifyPort(
int port);
138 private:
const std::shared_ptr<HttpWebApp> successHandler;
139 private:
const std::shared_ptr<HttpWebApp> failureHandler;
140 private:
const std::string successRedirectLocation;
141 private:
const std::string failureRedirectLocation;
142 private:
const std::string subject;
143 private:
const std::string from;
144 private:
const std::string to;
145 private:
const std::vector<std::string> cc;
146 private:
const bool useTLS;
147 private: Impl::CurlEmailSender emailSender;
148 private: std::unique_ptr<BalauLogger> log;
155 #pragma clang diagnostic pop 157 #endif // COM_BORA_SOFTWARE__BALAU_NETWORK_HTTP_SERVER_HTTP_WEB_APPS__EMAIL_SENDING_HTTP_WEB_APP std::unordered_map< std::string, std::string > ParameterMap
The map type that holds request body parameters.
Definition: EmailSendingHttpWebApp.hpp:56
Manages the handling of HTTP messages and WebSocket upgrade requests in an HTTP connection.
Definition: HttpSession.hpp:46
An HTTP web application handler that sends an email when a post request is made.
Definition: EmailSendingHttpWebApp.hpp:48
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.
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
Abstract base class of HTTP web application handlers.
EmailSendingHttpWebApp(BodyGenerator bodyGenerator_, std::shared_ptr< HttpWebApp > successHandler_, std::shared_ptr< HttpWebApp > failureHandler_, std::string host, unsigned short port, std::string user, std::string pw, std::string userAgent, std::string subject_, std::string from_, std::string to_, std::vector< std::string > cc_={}, bool useTLS_=true)
Construct an email sender handler with success/failure handlers.
Request< StringBody > StringRequest
A request with a string body.
Definition: NetworkTypes.hpp:267
void handlePostRequest(HttpSession &session, const StringRequest &request, std::map< std::string, std::string > &variables) override
Handle a POST request.
std::function< std::string(HttpSession &session, const StringRequest &request, std::map< std::string, std::string > &variables, const ParameterMap &)> BodyGenerator
The type of the body generator function.
Definition: EmailSendingHttpWebApp.hpp:64