summaryrefslogtreecommitdiffhomepage
path: root/response.h
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-04-05 19:15:25 +0200
committerRoland Reichwein <mail@reichwein.it>2020-04-05 19:15:25 +0200
commit917d4574153fa57ea43e7410006f58aa5b1bbb0b (patch)
tree3d4535370f596a46740a434319e73daf7f2704ba /response.h
parentddc02ba7a6cc92d07cf073395b2d41347a8d35fb (diff)
Separate out response handling
Diffstat (limited to 'response.h')
-rw-r--r--response.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/response.h b/response.h
new file mode 100644
index 0000000..a093320
--- /dev/null
+++ b/response.h
@@ -0,0 +1,40 @@
+#pragma once
+
+#include "config.h"
+
+#include <boost/beast/http.hpp>
+
+#include <exception>
+#include <string>
+
+namespace beast = boost::beast; // from <boost/beast.hpp>
+namespace http = beast::http; // from <boost/beast/http.hpp>
+
+class http_exception: public std::exception
+{
+ std::string m_message;
+public:
+ http_exception(std::string message);
+ virtual const char* what() const noexcept;
+};
+
+class bad_request_exception: public http_exception
+{
+public:
+ bad_request_exception(std::string message);
+};
+
+class not_found_exception: public http_exception
+{
+public:
+ not_found_exception(std::string message);
+};
+
+class server_error_exception: public http_exception
+{
+public:
+ server_error_exception(std::string message);
+};
+
+std::string extend_index_html(std::string path);
+std::string generate_response(http::request<http::string_body>& req, const Config& config, const Socket& socket);