2020-11-25 00:20:41 +01:00
|
|
|
#include "rdn_application.h"
|
|
|
|
|
2020-11-25 13:28:34 +01:00
|
|
|
#include "core/request.h"
|
2020-11-25 00:20:41 +01:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
2020-11-25 14:53:53 +01:00
|
|
|
#include "core/file_cache.h"
|
|
|
|
|
2020-11-25 00:20:41 +01:00
|
|
|
void RDNApplication::index(Request *request) {
|
2020-11-25 14:53:53 +01:00
|
|
|
std::string body;
|
|
|
|
|
|
|
|
if (FileCache::get_singleton()->get_cached_body("index", &body)) {
|
|
|
|
request->response->setBody(body);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
body = "<html>hello world aaaaa </html>";
|
2020-11-25 00:20:41 +01:00
|
|
|
|
2020-11-25 14:53:53 +01:00
|
|
|
FileCache::get_singleton()->set_cached_body("index", body);
|
2020-11-25 00:20:41 +01:00
|
|
|
|
|
|
|
request->response->setBody(body);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RDNApplication::session_middleware_func(Request *request) {
|
2020-11-25 14:53:53 +01:00
|
|
|
std::cout << "dddd" << std::endl;
|
2020-11-25 00:20:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void RDNApplication::setup_routes() {
|
|
|
|
Application::setup_routes();
|
|
|
|
|
|
|
|
index_func = index;
|
|
|
|
|
|
|
|
main_route_map["asd"] = index;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RDNApplication::setup_middleware() {
|
|
|
|
Application::setup_middleware();
|
|
|
|
|
|
|
|
middlewares.push_back(RDNApplication::session_middleware_func);
|
|
|
|
}
|
|
|
|
|
|
|
|
RDNApplication::RDNApplication() :
|
|
|
|
Application() {
|
|
|
|
}
|
|
|
|
|
|
|
|
RDNApplication::~RDNApplication() {
|
|
|
|
}
|