diff --git a/example/main.cpp b/example/main.cpp index 9711183..12780c0 100644 --- a/example/main.cpp +++ b/example/main.cpp @@ -11,6 +11,7 @@ // that the code could be more readable ¯\_(ツ)_/¯ using namespace expresso::core; using namespace expresso::enums; +using namespace expresso::messages; using namespace expresso::middleware; // Global variable, just for fun :) diff --git a/include/expresso/core/router.h b/include/expresso/core/router.h index 3d48a0c..04c6459 100644 --- a/include/expresso/core/router.h +++ b/include/expresso/core/router.h @@ -8,14 +8,23 @@ namespace core { class Router { private: - std::map getMap; - std::map postMap; - std::map putMap; - std::map + std::map + getMap; + std::map + postMap; + std::map + putMap; + std::map patchMap; - std::map + std::map deleteMap; - std::map + std::map optionsMap; std::map routerMap; @@ -24,33 +33,43 @@ class Router { std::vector> middlewares; - bool handleMiddlewares(Request &request, Response &response); - std::map & + bool handleMiddlewares(expresso::messages::Request &request, + expresso::messages::Response &response); + std::map & fetchMapFromMethod(expresso::enums::method method); void addRoute(expresso::enums::method method, std::string path, - void (*handler)(Request &request, Response &response)); + void (*handler)(expresso::messages::Request &request, + expresso::messages::Response &response)); public: Router(); ~Router(); void get(std::string path, - void (*handler)(Request &request, Response &response)); + void (*handler)(expresso::messages::Request &request, + expresso::messages::Response &response)); void post(std::string path, - void (*handler)(Request &request, Response &response)); + void (*handler)(expresso::messages::Request &request, + expresso::messages::Response &response)); void put(std::string path, - void (*handler)(Request &request, Response &response)); + void (*handler)(expresso::messages::Request &request, + expresso::messages::Response &response)); void patch(std::string path, - void (*handler)(Request &request, Response &response)); + void (*handler)(expresso::messages::Request &request, + expresso::messages::Response &response)); void del(std::string path, - void (*handler)(Request &request, Response &response)); + void (*handler)(expresso::messages::Request &request, + expresso::messages::Response &response)); void options(std::string path, - void (*handler)(Request &request, Response &response)); + void (*handler)(expresso::messages::Request &request, + expresso::messages::Response &response)); void use(std::string path, Router *router); void use(std::unique_ptr middleware); - void handleRequest(Request &request, Response &response); + void handleRequest(expresso::messages::Request &request, + expresso::messages::Response &response); }; } // namespace core diff --git a/include/expresso/core/server.h b/include/expresso/core/server.h index 9a2d59d..039f368 100644 --- a/include/expresso/core/server.h +++ b/include/expresso/core/server.h @@ -25,7 +25,7 @@ class Server : public Router { void acceptConnections(); void handleConnection(int clientSocket); - expresso::core::Request makeRequest(std::string &request) noexcept(false); + expresso::messages::Request makeRequest(std::string &request) noexcept(false); nexus::pool threadPool; public: diff --git a/include/expresso/core/cookie.h b/include/expresso/messages/cookie.h similarity index 89% rename from include/expresso/core/cookie.h rename to include/expresso/messages/cookie.h index f740bd6..4cc8a83 100644 --- a/include/expresso/core/cookie.h +++ b/include/expresso/messages/cookie.h @@ -6,7 +6,7 @@ namespace expresso { -namespace core { +namespace messages { class Cookie { public: @@ -28,6 +28,6 @@ class Cookie { std::string serialize(); }; -} // namespace core +} // namespace messages } // namespace expresso \ No newline at end of file diff --git a/include/expresso/core/request.h b/include/expresso/messages/request.h similarity index 83% rename from include/expresso/core/request.h rename to include/expresso/messages/request.h index c710e0d..99e67e9 100644 --- a/include/expresso/core/request.h +++ b/include/expresso/messages/request.h @@ -1,10 +1,10 @@ #pragma once -#include +#include namespace expresso { -namespace core { +namespace messages { class Request { private: @@ -31,11 +31,11 @@ class Request { std::map params; std::map queries; - expresso::core::Response *res; + expresso::messages::Response *res; void print(); }; -} // namespace core +} // namespace messages } // namespace expresso diff --git a/include/expresso/core/response.h b/include/expresso/messages/response.h similarity index 93% rename from include/expresso/core/response.h rename to include/expresso/messages/response.h index 956bc3a..e5d4798 100644 --- a/include/expresso/core/response.h +++ b/include/expresso/messages/response.h @@ -9,13 +9,13 @@ #include #include -#include #include #include +#include namespace expresso { -namespace core { +namespace messages { class Response { private: @@ -54,6 +54,6 @@ class Response { void print(); }; -} // namespace core +} // namespace messages } // namespace expresso \ No newline at end of file diff --git a/include/expresso/middleware/cacher.h b/include/expresso/middleware/cacher.h index 16dbb1b..4b0ef32 100644 --- a/include/expresso/middleware/cacher.h +++ b/include/expresso/middleware/cacher.h @@ -17,8 +17,8 @@ class Cacher : public Middleware { Cacher(uint32_t maxAge = 3600, bool isPrivate = false); ~Cacher(); - bool use(expresso::core::Request &req, - expresso::core::Response &res) override; + bool use(expresso::messages::Request &req, + expresso::messages::Response &res) override; }; } // namespace middleware diff --git a/include/expresso/middleware/cookie_parser.h b/include/expresso/middleware/cookie_parser.h index 91c391f..075e062 100644 --- a/include/expresso/middleware/cookie_parser.h +++ b/include/expresso/middleware/cookie_parser.h @@ -12,8 +12,8 @@ class CookieParser : public Middleware { CookieParser(); ~CookieParser(); - bool use(expresso::core::Request &req, - expresso::core::Response &res) override; + bool use(expresso::messages::Request &req, + expresso::messages::Response &res) override; }; } // namespace middleware diff --git a/include/expresso/middleware/cors.h b/include/expresso/middleware/cors.h index 44adbdb..b058bf9 100644 --- a/include/expresso/middleware/cors.h +++ b/include/expresso/middleware/cors.h @@ -27,8 +27,8 @@ class Cors : public Middleware { void allowHeader(std::string header); void allowCredentials(bool credentials); - bool use(expresso::core::Request &req, - expresso::core::Response &res) override; + bool use(expresso::messages::Request &req, + expresso::messages::Response &res) override; }; } // namespace middleware diff --git a/include/expresso/middleware/date.h b/include/expresso/middleware/date.h index 17c77bc..4ebdd09 100644 --- a/include/expresso/middleware/date.h +++ b/include/expresso/middleware/date.h @@ -12,8 +12,8 @@ class Date : public Middleware { Date(); ~Date(); - bool use(expresso::core::Request &req, - expresso::core::Response &res) override; + bool use(expresso::messages::Request &req, + expresso::messages::Response &res) override; }; } // namespace middleware diff --git a/include/expresso/middleware/middleware.h b/include/expresso/middleware/middleware.h index 7ca21c6..8219463 100644 --- a/include/expresso/middleware/middleware.h +++ b/include/expresso/middleware/middleware.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace expresso { @@ -12,8 +12,8 @@ class Middleware { Middleware(); virtual ~Middleware() = default; - virtual bool use(expresso::core::Request &req, - expresso::core::Response &res) = 0; + virtual bool use(expresso::messages::Request &req, + expresso::messages::Response &res) = 0; }; } // namespace middleware diff --git a/include/expresso/middleware/static_serve.h b/include/expresso/middleware/static_serve.h index e0f4deb..aa4efd7 100644 --- a/include/expresso/middleware/static_serve.h +++ b/include/expresso/middleware/static_serve.h @@ -13,15 +13,15 @@ class StaticServe : public Middleware { std::string dirname; std::pair getRange(const std::string &range); - std::string getFolderHTML(expresso::core::Request &req, + std::string getFolderHTML(expresso::messages::Request &req, const std::string &localPath); public: StaticServe(std::string dirname, bool showListing = false); ~StaticServe(); - bool use(expresso::core::Request &req, - expresso::core::Response &res) override; + bool use(expresso::messages::Request &req, + expresso::messages::Response &res) override; }; } // namespace middleware diff --git a/include/expresso/middleware/version.h b/include/expresso/middleware/version.h index b3112a7..b11a180 100644 --- a/include/expresso/middleware/version.h +++ b/include/expresso/middleware/version.h @@ -13,8 +13,8 @@ class Version : public Middleware { Version(); ~Version(); - bool use(expresso::core::Request &request, - expresso::core::Response &response) override; + bool use(expresso::messages::Request &request, + expresso::messages::Response &response) override; }; } // namespace middleware diff --git a/src/core/router.cpp b/src/core/router.cpp index 33932fe..f6192ca 100644 --- a/src/core/router.cpp +++ b/src/core/router.cpp @@ -22,44 +22,44 @@ expresso::core::Router::~Router() { return; } -void expresso::core::Router::get(std::string path, - void (*handler)(Request &request, - Response &response)) { +void expresso::core::Router::get( + std::string path, void (*handler)(expresso::messages::Request &request, + expresso::messages::Response &response)) { this->addRoute(expresso::enums::method::GET, path, handler); return; } -void expresso::core::Router::post(std::string path, - void (*handler)(Request &request, - Response &response)) { +void expresso::core::Router::post( + std::string path, void (*handler)(expresso::messages::Request &request, + expresso::messages::Response &response)) { this->addRoute(expresso::enums::method::POST, path, handler); return; } -void expresso::core::Router::put(std::string path, - void (*handler)(Request &request, - Response &response)) { +void expresso::core::Router::put( + std::string path, void (*handler)(expresso::messages::Request &request, + expresso::messages::Response &response)) { this->addRoute(expresso::enums::method::PUT, path, handler); return; } -void expresso::core::Router::patch(std::string path, - void (*handler)(Request &request, - Response &response)) { +void expresso::core::Router::patch( + std::string path, void (*handler)(expresso::messages::Request &request, + expresso::messages::Response &response)) { this->addRoute(expresso::enums::method::PATCH, path, handler); return; } -void expresso::core::Router::del(std::string path, - void (*handler)(Request &request, - Response &response)) { +void expresso::core::Router::del( + std::string path, void (*handler)(expresso::messages::Request &request, + expresso::messages::Response &response)) { this->addRoute(expresso::enums::method::DELETE, path, handler); return; } -void expresso::core::Router::options(std::string path, - void (*handler)(Request &request, - Response &response)) { +void expresso::core::Router::options( + std::string path, void (*handler)(expresso::messages::Request &request, + expresso::messages::Response &response)) { this->addRoute(expresso::enums::method::OPTIONS, path, handler); return; } @@ -86,8 +86,9 @@ void expresso::core::Router::use( return; } -void expresso::core::Router::handleRequest(Request &request, - Response &response) { +void expresso::core::Router::handleRequest( + expresso::messages::Request &request, + expresso::messages::Response &response) { if (!this->handleMiddlewares(request, response)) { return; } @@ -96,7 +97,8 @@ void expresso::core::Router::handleRequest(Request &request, request.tempPath = request.tempPath.substr(1, request.tempPath.size()); } - std::map &map = + std::map &map = this->fetchMapFromMethod(request.method); if (map.find(request.tempPath) != map.end()) { return map[request.tempPath](request, response); @@ -138,8 +140,9 @@ void expresso::core::Router::handleRequest(Request &request, return; } -bool expresso::core::Router::handleMiddlewares(Request &request, - Response &response) { +bool expresso::core::Router::handleMiddlewares( + expresso::messages::Request &request, + expresso::messages::Response &response) { for (const std::unique_ptr &middleware : this->middlewares) { if (!middleware->use(request, response)) { @@ -151,8 +154,9 @@ bool expresso::core::Router::handleMiddlewares(Request &request, return true; } -std::map & +std::map & expresso::core::Router::fetchMapFromMethod(expresso::enums::method method) { switch (method) { case expresso::enums::method::GET: @@ -170,26 +174,29 @@ expresso::core::Router::fetchMapFromMethod(expresso::enums::method method) { return this->optionsMap; default: logger::error("Invalid method: " + std::to_string(static_cast(method)), - "std::map " + "std::map " "&expresso::core::Router::fetchRouterFromMethod(expresso::" "enums::method method)"); return this->getMap; } } -void expresso::core::Router::addRoute(expresso::enums::method method, - std::string path, - void (*handler)(Request &request, - Response &response)) { +void expresso::core::Router::addRoute( + expresso::enums::method method, std::string path, + void (*handler)(expresso::messages::Request &request, + expresso::messages::Response &response)) { if (path[0] != '/') { logger::error("Router path must start with a '/', given: " + path, "void expresso::core::Router::put(std::string path, void " - "(*handler)(Request &request, Response &response))"); + "(*handler)(expresso::messages::Request &request, Response " + "&response))"); return; } - std::map &map = + std::map &map = this->fetchMapFromMethod(method); map[path.substr(1, path.size())] = handler; return; diff --git a/src/core/server.cpp b/src/core/server.cpp index 60994e5..b28a6f0 100644 --- a/src/core/server.cpp +++ b/src/core/server.cpp @@ -104,10 +104,10 @@ void expresso::core::Server::handleConnection(int clientSocket) { charRequest.resize(totalBytesRead); std::string request(charRequest.data()); - Response *res = new Response(clientSocket); + expresso::messages::Response *res = new expresso::messages::Response(clientSocket); try { - Request req = this->makeRequest(request); + expresso::messages::Request req = this->makeRequest(request); req.res = res; this->handleRequest(req, *res); delete res; @@ -122,9 +122,9 @@ void expresso::core::Server::handleConnection(int clientSocket) { return; } -expresso::core::Request +expresso::messages::Request expresso::core::Server::makeRequest(std::string &request) noexcept(false) { - Request req; + expresso::messages::Request req; std::string line; std::istringstream stream(request); std::getline(stream, line); diff --git a/src/core/cookie.cpp b/src/messages/cookie.cpp similarity index 83% rename from src/core/cookie.cpp rename to src/messages/cookie.cpp index 55688f9..122dcd6 100644 --- a/src/core/cookie.cpp +++ b/src/messages/cookie.cpp @@ -1,14 +1,14 @@ -#include +#include -expresso::core::Cookie::Cookie() +expresso::messages::Cookie::Cookie() : secure(false), httpOnly(false), partitioned(false), name(""), value(""), domain(""), path(""), expires(""), maxAge(""), sameSite("") { return; } -expresso::core::Cookie::~Cookie() { return; } +expresso::messages::Cookie::~Cookie() { return; } -std::string expresso::core::Cookie::serialize() { +std::string expresso::messages::Cookie::serialize() { std::string cookieString = this->name + "=" + brewtils::url::encode(this->value); if (!this->domain.empty()) { diff --git a/src/core/request.cpp b/src/messages/request.cpp similarity index 80% rename from src/core/request.cpp rename to src/messages/request.cpp index f184682..f71da70 100644 --- a/src/core/request.cpp +++ b/src/messages/request.cpp @@ -1,13 +1,13 @@ -#include +#include -expresso::core::Request::Request() +expresso::messages::Request::Request() : xhr(false), res(nullptr), contentLength(0) { return; } -expresso::core::Request::~Request() { return; } +expresso::messages::Request::~Request() { return; } -void expresso::core::Request::print() { +void expresso::messages::Request::print() { logger::info("Request: "); logger::info(" host: " + this->host); @@ -19,7 +19,7 @@ void expresso::core::Request::print() { logger::info(this->body.dumps(2, 2)); logger::info(" cookies: "); - for (expresso::core::Cookie *cookie : this->cookies) { + for (expresso::messages::Cookie *cookie : this->cookies) { logger::info(" " + cookie->serialize()); } diff --git a/src/core/response.cpp b/src/messages/response.cpp similarity index 76% rename from src/core/response.cpp rename to src/messages/response.cpp index 033b05e..6e09845 100644 --- a/src/core/response.cpp +++ b/src/messages/response.cpp @@ -1,7 +1,7 @@ -#include #include +#include -expresso::core::Response::Response(int clientSocket) +expresso::messages::Response::Response(int clientSocket) : hasEnded(false), socket(clientSocket), statusCode(expresso::enums::STATUS_CODE::OK), message("") { this->set("connection", "close"); @@ -9,32 +9,32 @@ expresso::core::Response::Response(int clientSocket) return; } -expresso::core::Response::~Response() { +expresso::messages::Response::~Response() { if (!this->hasEnded) { this->sendToClient(); } - for (expresso::core::Cookie *cookie : this->cookies) { + for (expresso::messages::Cookie *cookie : this->cookies) { delete cookie; } return; } -void expresso::core::Response::set(std::string headerName, - std::string headerValue) { +void expresso::messages::Response::set(std::string headerName, + std::string headerValue) { this->headers[brewtils::string::lower(headerName)] = headerValue; return; } -void expresso::core::Response::setCookie(Cookie *cookie) { +void expresso::messages::Response::setCookie(Cookie *cookie) { this->cookies.push_back(cookie); return; } -std::string expresso::core::Response::get(std::string headerName) { +std::string expresso::messages::Response::get(std::string headerName) { headerName = brewtils::string::lower(headerName); if (this->headers.find(headerName) != this->headers.end()) { return this->headers[headerName]; @@ -43,14 +43,15 @@ std::string expresso::core::Response::get(std::string headerName) { } } -expresso::core::Response & -expresso::core::Response::status(expresso::enums::STATUS_CODE code) { +expresso::messages::Response & +expresso::messages::Response::status(expresso::enums::STATUS_CODE code) { this->statusCode = code; return *this; } -expresso::core::Response &expresso::core::Response::send(std::string response) { +expresso::messages::Response & +expresso::messages::Response::send(std::string response) { this->message = brewtils::string::replace(response, "\n", "\r\n"); this->message += "\r\n"; this->set("content-type", "text/plain"); @@ -58,23 +59,24 @@ expresso::core::Response &expresso::core::Response::send(std::string response) { return *this; } -expresso::core::Response &expresso::core::Response::json(std::string response) { +expresso::messages::Response & +expresso::messages::Response::json(std::string response) { this->message = response; this->set("content-type", "application/json"); return *this; } -expresso::core::Response & -expresso::core::Response::json(json::object response) { +expresso::messages::Response & +expresso::messages::Response::json(json::object response) { this->message = response.dumps(0); this->set("content-type", "application/json"); return *this; } -void expresso::core::Response::sendFile(const std::string &path, int64_t start, - int64_t end) { +void expresso::messages::Response::sendFile(const std::string &path, + int64_t start, int64_t end) { std::string availableFile = expresso::helpers::getAvailableFile(path); if (availableFile.empty() || !brewtils::os::file::exists(availableFile)) { return this->sendNotFound(); @@ -129,7 +131,7 @@ void expresso::core::Response::sendFile(const std::string &path, int64_t start, } } } catch (const std::exception &e) { - logger::error(e.what(), "void expresso::core::Response::sendFile(const " + logger::error(e.what(), "void expresso::messages::Response::sendFile(const " "std::string &path, int64_t start, int64_t end)"); } if (file.is_open()) { @@ -139,8 +141,8 @@ void expresso::core::Response::sendFile(const std::string &path, int64_t start, return; } -void expresso::core::Response::sendFiles(const std::set &paths, - const std::string &zipFileName) { +void expresso::messages::Response::sendFiles(const std::set &paths, + const std::string &zipFileName) { this->headers.erase("content-length"); this->set("transfer-encoding", "chunked"); this->set("content-type", brewtils::os::file::getMimeType(zipFileName)); @@ -176,21 +178,22 @@ void expresso::core::Response::sendFiles(const std::set &paths, this->hasEnded = true; } } catch (const std::exception &e) { - logger::error(e.what(), "void expresso::core::Response::sendFiles(const " - "std::set &paths, const std::string " - "&zipFileName)"); + logger::error(e.what(), + "void expresso::messages::Response::sendFiles(const " + "std::set &paths, const std::string " + "&zipFileName)"); } return; } -void expresso::core::Response::sendNotFound() { +void expresso::messages::Response::sendNotFound() { this->status(expresso::enums::STATUS_CODE::NOT_FOUND).send("Not Found").end(); return; } -void expresso::core::Response::sendInvalidRange() { +void expresso::messages::Response::sendInvalidRange() { this->set("content-range", "bytes */"); this->status(expresso::enums::STATUS_CODE::RANGE_NOT_SATISFIABLE) .send("Invalid Range") @@ -199,7 +202,7 @@ void expresso::core::Response::sendInvalidRange() { return; } -void expresso::core::Response::end() { +void expresso::messages::Response::end() { if (!this->hasEnded) { this->sendToClient(); } @@ -207,7 +210,7 @@ void expresso::core::Response::end() { return; } -void expresso::core::Response::print() { +void expresso::messages::Response::print() { logger::info("Response: "); logger::info(" statusCode: " + std::to_string(this->statusCode)); logger::info(" headers: "); @@ -220,7 +223,7 @@ void expresso::core::Response::print() { return; } -void expresso::core::Response::sendToClient() { +void expresso::messages::Response::sendToClient() { this->set("content-length", std::to_string(this->message.length())); this->sendHeaders(); if (this->hasEnded) { @@ -233,7 +236,7 @@ void expresso::core::Response::sendToClient() { return; } -void expresso::core::Response::sendHeaders() { +void expresso::messages::Response::sendHeaders() { std::string header = "HTTP/1.1 " + std::to_string(this->statusCode) + "\r\n"; for (std::pair it : this->headers) { header += it.first + ": " + it.second + "\r\n"; diff --git a/src/middleware/cacher.cpp b/src/middleware/cacher.cpp index e522676..77faddc 100644 --- a/src/middleware/cacher.cpp +++ b/src/middleware/cacher.cpp @@ -12,8 +12,8 @@ expresso::middleware::Cacher::Cacher(uint32_t maxAge, bool isPrivate) expresso::middleware::Cacher::~Cacher() { return; } -bool expresso::middleware::Cacher::use(expresso::core::Request &req, - expresso::core::Response &res) { +bool expresso::middleware::Cacher::use(expresso::messages::Request &req, + expresso::messages::Response &res) { res.set("cache-control", this->serialized); return true; } \ No newline at end of file diff --git a/src/middleware/cookie_parser.cpp b/src/middleware/cookie_parser.cpp index b6fb86d..d78715d 100644 --- a/src/middleware/cookie_parser.cpp +++ b/src/middleware/cookie_parser.cpp @@ -4,8 +4,8 @@ expresso::middleware::CookieParser::CookieParser() { return; } expresso::middleware::CookieParser::~CookieParser() { return; } -bool expresso::middleware::CookieParser::use(expresso::core::Request &req, - expresso::core::Response &res) { +bool expresso::middleware::CookieParser::use( + expresso::messages::Request &req, expresso::messages::Response &res) { std::string cookieString = req.headers["cookie"]; if (cookieString.empty()) { return true; @@ -14,7 +14,7 @@ bool expresso::middleware::CookieParser::use(expresso::core::Request &req, std::vector cookies = brewtils::string::split(cookieString, ";"); std::vector cookiePair; for (std::string &cookieStr : cookies) { - expresso::core::Cookie *cookie = new expresso::core::Cookie(); + expresso::messages::Cookie *cookie = new expresso::messages::Cookie(); cookiePair = brewtils::string::split(cookieStr, "="); cookie->name = brewtils::string::trim(cookiePair[0]); cookie->value = brewtils::string::trim(cookiePair[1]); diff --git a/src/middleware/cors.cpp b/src/middleware/cors.cpp index ff8a97e..994d22c 100644 --- a/src/middleware/cors.cpp +++ b/src/middleware/cors.cpp @@ -57,8 +57,8 @@ void expresso::middleware::Cors::allowCredentials(bool credentials) { return; } -bool expresso::middleware::Cors::use(expresso::core::Request &req, - expresso::core::Response &res) { +bool expresso::middleware::Cors::use(expresso::messages::Request &req, + expresso::messages::Response &res) { if (this->allowAllOrigins) { return true; } diff --git a/src/middleware/date.cpp b/src/middleware/date.cpp index 5aa36bf..cb889f4 100644 --- a/src/middleware/date.cpp +++ b/src/middleware/date.cpp @@ -4,8 +4,8 @@ expresso::middleware::Date::Date() { return; } expresso::middleware::Date::~Date() { return; } -bool expresso::middleware::Date::use(expresso::core::Request &req, - expresso::core::Response &res) { +bool expresso::middleware::Date::use(expresso::messages::Request &req, + expresso::messages::Response &res) { res.set("date", brewtils::date::getCurrentUTC()); return true; } \ No newline at end of file diff --git a/src/middleware/static_serve.cpp b/src/middleware/static_serve.cpp index 659f28f..b4c7b31 100644 --- a/src/middleware/static_serve.cpp +++ b/src/middleware/static_serve.cpp @@ -9,8 +9,8 @@ expresso::middleware::StaticServe::StaticServe(std::string dirname, expresso::middleware::StaticServe::~StaticServe() { return; } -bool expresso::middleware::StaticServe::use(expresso::core::Request &req, - expresso::core::Response &res) { +bool expresso::middleware::StaticServe::use(expresso::messages::Request &req, + expresso::messages::Response &res) { if (req.method != expresso::enums::method::GET) { return true; } @@ -69,7 +69,7 @@ expresso::middleware::StaticServe::getRange(const std::string &range) { } std::string -expresso::middleware::StaticServe::getFolderHTML(expresso::core::Request &req, +expresso::middleware::StaticServe::getFolderHTML(expresso::messages::Request &req, const std::string &localPath) { std::ostringstream oss; const std::string urlPath = req.path; diff --git a/src/middleware/version.cpp b/src/middleware/version.cpp index 07ceef8..bfba9de 100644 --- a/src/middleware/version.cpp +++ b/src/middleware/version.cpp @@ -9,8 +9,8 @@ expresso::middleware::Version::Version() { expresso::middleware::Version::~Version() { return; } -bool expresso::middleware::Version::use(expresso::core::Request &request, - expresso::core::Response &response) { +bool expresso::middleware::Version::use(expresso::messages::Request &request, + expresso::messages::Response &response) { response.set("expresso", this->version); response.set("x-powered-by", "Expresso/" + this->version); return true;