From 09f45879c2b2e63689265924cb700dee5f02f653 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Fri, 22 Oct 2021 17:55:51 +0200 Subject: Added 404 error page. * changed Blog constructor fn sig Signed-off-by: Toni Uhlig --- src/EventManager.cpp | 9 +++++++-- src/content/blog/Blog.cpp | 2 +- src/content/blog/Blog.hpp | 2 +- src/main.cpp | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/EventManager.cpp b/src/EventManager.cpp index 1faea6d..81b949d 100644 --- a/src/EventManager.cpp +++ b/src/EventManager.cpp @@ -112,8 +112,13 @@ static inline void default_evhttp_callback(struct evhttp_request * const req, Ev struct evbuffer * const output = evbuffer_new(); if (output != nullptr) { - evbuffer_add_printf(output, "%s\n", "default page"); - evhttp_send_reply(req, 200, "OK", output); + static char const * const page_404 = "\n" + "\n" + "\t404 Not Found\n" + "\t

Not Found

The requested URI was not found.\n" + "\n"; + evbuffer_add_printf(output, "%s\n", page_404); + evhttp_send_reply(req, 404, "Not found", output); evbuffer_free(output); } } diff --git a/src/content/blog/Blog.cpp b/src/content/blog/Blog.cpp index 47a3292..a472b97 100644 --- a/src/content/blog/Blog.cpp +++ b/src/content/blog/Blog.cpp @@ -2,7 +2,7 @@ #include -Blog::Blog(std::string uriBasePath, std::string mainTemplatePath, std::string blogPath) +Blog::Blog(std::string uriBasePath, std::string blogPath, std::string mainTemplatePath) : Content(), m_UriBasePath(uriBasePath), m_MainTemplatePath(mainTemplatePath), diff --git a/src/content/blog/Blog.hpp b/src/content/blog/Blog.hpp index d58cd72..06f279c 100644 --- a/src/content/blog/Blog.hpp +++ b/src/content/blog/Blog.hpp @@ -32,7 +32,7 @@ using BlogEntries = std::vector; class Blog : public Content { public: - explicit Blog(std::string uriBasePath, std::string mainTemplatePath, std::string blogPath); + explicit Blog(std::string uriBasePath, std::string blogPath, std::string mainTemplatePath); bool Init(); void Shutdown(); diff --git a/src/main.cpp b/src/main.cpp index dcd24a2..61407d8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -70,7 +70,7 @@ int main(int argc, char ** argv) } cmgr->RegisterModule(std::make_shared("/", "./pages", "index.html")); - cmgr->RegisterModule(std::make_shared("/blog", "blog/index.html", "./blog")); + cmgr->RegisterModule(std::make_shared("/blog", "./blog", "blog/index.html")); if (cmgr->InitAll() == false) { -- cgit v1.2.3