implement consistent use of virtual class
This commit is contained in:
parent
b035f4b923
commit
55fb0d0b0f
|
@ -0,0 +1,12 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "StaticFileHandler.H"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class MediocreSimpleStaticFileHandler :public StaticFileHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int answer_pathreq(const char * const path, struct mg_connection *conn);
|
||||||
|
std::string cleanpath(const char * const);
|
||||||
|
|
||||||
|
};
|
|
@ -1,20 +1,14 @@
|
||||||
#include "MediocreSimpleStaticFileHandler.H"
|
#include "MediocreSimpleStaticFileHandler.H"
|
||||||
//#include "InputMemmoryFile.H"
|
|
||||||
class MediocreSimpleStaticFileHandler :StaticFileHandler
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
std::string cleanpath (const char * const path){
|
std::string MediocreSimpleStaticFileHandler::cleanpath (const char * const path){
|
||||||
//adds no security at all
|
//adds no security at all
|
||||||
return std::string(path);
|
return std::string(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
int MediocreSimpleStaticFileHandler::answer_pathreq(const char * const path,
|
||||||
int answer_pathreq(const char * const path,
|
|
||||||
struct mg_connection *conn)
|
struct mg_connection *conn)
|
||||||
{
|
{
|
||||||
mg_send_file(conn,cleanpath(path).c_str());
|
mg_send_file(conn,cleanpath(path).c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
class UltraSimpleStaticFileHandler :public StaticFileHandler
|
class UltraSimpleStaticFileHandler :public StaticFileHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
~UltraSimpleStaticFileHandler();
|
||||||
int answer_pathreq(const char * const path, struct mg_connection *conn);
|
int answer_pathreq(const char * const path, struct mg_connection *conn);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,20 +22,17 @@ static const char * hello_world_html = u8R"HERE(
|
||||||
</body>
|
</body>
|
||||||
</html>)HERE";
|
</html>)HERE";
|
||||||
|
|
||||||
|
UltraSimpleStaticFileHandler::~UltraSimpleStaticFileHandler() {}
|
||||||
|
|
||||||
class UltraSimpleStaticFileHandler : StaticFileHandler
|
int
|
||||||
{
|
UltraSimpleStaticFileHandler::answer_pathreq(const char * const path,
|
||||||
public:
|
struct mg_connection *conn)
|
||||||
int answer_pathreq(const char * const path, struct mg_connection *conn)
|
|
||||||
{
|
{
|
||||||
mg_printf(conn, "HTTP/1.0 200 OK\r\n"
|
mg_printf(conn, "HTTP/1.0 200 OK\r\n"
|
||||||
"Content-Length: %d\r\n"
|
"Content-Length: %d\r\n"
|
||||||
"Content-Type: text/html\r\n\r\n%s",
|
"Content-Type: text/html\r\n\r\n%s",
|
||||||
hello_world_html.size(),
|
sizeof(hello_world_html),
|
||||||
hello_world_html.c_str());
|
hello_world_html);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user