mirror of
https://github.com/Relintai/wp_saver_rcpp_fw.git
synced 2024-11-10 00:52:12 +01:00
Run the web app when launched without parameters. Also cleanups.
This commit is contained in:
parent
1044749d2a
commit
a6a8b11871
@ -21,12 +21,12 @@ void WPApplication::index(Object *instance, Request *request) {
|
||||
}
|
||||
|
||||
void WPApplication::blog(Object *instance, Request *request) {
|
||||
request->body += "test";
|
||||
request->body += "test blog";
|
||||
request->compile_and_send_body();
|
||||
}
|
||||
|
||||
void WPApplication::routing_middleware(Object *instance, Request *request) {
|
||||
std::string path = request->get_path_full();
|
||||
String path = request->get_path_full();
|
||||
|
||||
WPApplication *app = Object::cast_to<WPApplication>(instance);
|
||||
|
||||
@ -36,19 +36,26 @@ void WPApplication::routing_middleware(Object *instance, Request *request) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool handled = false;
|
||||
|
||||
if (request->get_path_segment_count() == 0) {
|
||||
handled = true;
|
||||
|
||||
request->handler_instance = app->index_func;
|
||||
} else {
|
||||
const std::string main_route = request->get_current_path_segment();
|
||||
|
||||
|
||||
const String main_route = request->get_current_path_segment();
|
||||
|
||||
request->push_path();
|
||||
|
||||
if (main_route == "blog") {
|
||||
handled = true;
|
||||
request->handler_instance = app->blog_func;
|
||||
}
|
||||
}
|
||||
|
||||
if (!request->handler_instance.handler_func) {
|
||||
if (!handled) {
|
||||
app->send_error(404, request);
|
||||
|
||||
return;
|
||||
|
5
main.cpp
5
main.cpp
@ -16,6 +16,7 @@
|
||||
#include "core/settings.h"
|
||||
|
||||
#include "app/wp_downloader.h"
|
||||
#include "app/wp_application.h"
|
||||
|
||||
void initialize_backends() {
|
||||
initialize_database_backends();
|
||||
@ -65,12 +66,11 @@ int main(int argc, char **argv, char **envp) {
|
||||
|
||||
delete dbm;
|
||||
} else {
|
||||
/*
|
||||
FileCache *file_cache = new FileCache(true);
|
||||
file_cache->wwwroot = "./www";
|
||||
file_cache->wwwroot_refresh_cache();
|
||||
|
||||
DWebApplication *app = new DWebApplication();
|
||||
WPApplication *app = new WPApplication();
|
||||
app->load_settings();
|
||||
app->setup_routes();
|
||||
app->setup_middleware();
|
||||
@ -81,7 +81,6 @@ int main(int argc, char **argv, char **envp) {
|
||||
delete app;
|
||||
|
||||
delete file_cache;
|
||||
*/
|
||||
}
|
||||
|
||||
delete settings;
|
||||
|
Loading…
Reference in New Issue
Block a user