From ef18e705f4a32198758c2b7fc32bda14bf877dfc Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 8 Jan 2022 12:05:33 +0100 Subject: [PATCH] Added a new Middleware class. --- core/http/middleware.cpp | 14 ++++++++++++++ core/http/middleware.h | 21 +++++++++++++++++++++ core/http/web_root.h | 1 + 3 files changed, 36 insertions(+) create mode 100644 core/http/middleware.cpp create mode 100644 core/http/middleware.h diff --git a/core/http/middleware.cpp b/core/http/middleware.cpp new file mode 100644 index 0000000..ce4e025 --- /dev/null +++ b/core/http/middleware.cpp @@ -0,0 +1,14 @@ + +#include "middleware.h" + +#include "request.h" + +bool Middleware::on_before_handle_request_main(Request *request) { + return false; +} + +Middleware::Middleware() { +} + +Middleware::~Middleware() { +} \ No newline at end of file diff --git a/core/http/middleware.h b/core/http/middleware.h new file mode 100644 index 0000000..1c4bf73 --- /dev/null +++ b/core/http/middleware.h @@ -0,0 +1,21 @@ +#ifndef MIDDLEWARE_H +#define MIDDLEWARE_H + +#include "core/string.h" + +#include "core/reference.h" + +class Request; + +class Middleware : public Reference { + RCPP_OBJECT(Middleware, Reference); + +public: + //returnring true means handled, false, means continue + virtual bool on_before_handle_request_main(Request *request); + + Middleware(); + ~Middleware(); +}; + +#endif \ No newline at end of file diff --git a/core/http/web_root.h b/core/http/web_root.h index a348693..9bc4e2a 100644 --- a/core/http/web_root.h +++ b/core/http/web_root.h @@ -24,6 +24,7 @@ class Request; //Update the rest of the modules to the new systems +//remove middleware stack from request class WebRoot : public WebRouterNode { RCPP_OBJECT(WebRoot, WebRouterNode);