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 "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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -22,20 +22,17 @@ static const char * hello_world_html = u8R"HERE(
|
|||
</body>
|
||||
</html>)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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue