diff --git a/src/MediocreSimpleStaticFileHandler.H b/src/MediocreSimpleStaticFileHandler.H index e69de29..d13510b 100644 --- a/src/MediocreSimpleStaticFileHandler.H +++ b/src/MediocreSimpleStaticFileHandler.H @@ -0,0 +1,12 @@ +#pragma once + +#include "StaticFileHandler.H" +#include + +class MediocreSimpleStaticFileHandler :public StaticFileHandler +{ + public: + int answer_pathreq(const char * const path, struct mg_connection *conn); + std::string cleanpath(const char * const); + +}; diff --git a/src/MediocreSimpleStaticFileHandler.cc b/src/MediocreSimpleStaticFileHandler.cc index a5c29c2..e00bb8d 100644 --- a/src/MediocreSimpleStaticFileHandler.cc +++ b/src/MediocreSimpleStaticFileHandler.cc @@ -1,20 +1,14 @@ #include "MediocreSimpleStaticFileHandler.H" -//#include "InputMemmoryFile.H" -class MediocreSimpleStaticFileHandler :StaticFileHandler + +std::string MediocreSimpleStaticFileHandler::cleanpath (const char * const path){ + //adds no security at all + return std::string(path); +} + +int MediocreSimpleStaticFileHandler::answer_pathreq(const char * const path, + struct mg_connection *conn) { - private: - - std::string cleanpath (const char * const path){ - //adds no security at all - return std::string(path); - } - - public: - int answer_pathreq(const char * const path, - struct mg_connection *conn) - { - mg_send_file(conn,cleanpath(path).c_str()); - return 0; - } + mg_send_file(conn,cleanpath(path).c_str()); + return 0; } diff --git a/src/UltraSimpleStaticFileHandler.H b/src/UltraSimpleStaticFileHandler.H index 18ab847..9938371 100644 --- a/src/UltraSimpleStaticFileHandler.H +++ b/src/UltraSimpleStaticFileHandler.H @@ -4,7 +4,8 @@ class UltraSimpleStaticFileHandler :public StaticFileHandler { public: - int answer_pathreq(const char * const path, struct mg_connection *conn); + ~UltraSimpleStaticFileHandler(); + int answer_pathreq(const char * const path, struct mg_connection *conn); }; diff --git a/src/UltraSimpleStaticFileHandler.cc b/src/UltraSimpleStaticFileHandler.cc index 90ddb20..c8d3f9e 100644 --- a/src/UltraSimpleStaticFileHandler.cc +++ b/src/UltraSimpleStaticFileHandler.cc @@ -22,20 +22,17 @@ static const char * hello_world_html = u8R"HERE( )HERE"; +UltraSimpleStaticFileHandler::~UltraSimpleStaticFileHandler() {} -class UltraSimpleStaticFileHandler : StaticFileHandler +int +UltraSimpleStaticFileHandler::answer_pathreq(const char * const path, + struct mg_connection *conn) { - public: - int answer_pathreq(const char * const path, struct mg_connection *conn) - { - mg_printf(conn, "HTTP/1.0 200 OK\r\n" - "Content-Length: %d\r\n" - "Content-Type: text/html\r\n\r\n%s", - hello_world_html.size(), - hello_world_html.c_str()); - return 0; - } - -}; - + mg_printf(conn, "HTTP/1.0 200 OK\r\n" + "Content-Length: %d\r\n" + "Content-Type: text/html\r\n\r\n%s", + sizeof(hello_world_html), + hello_world_html); + return 0; +}