parent
44df053023
commit
6557a866ef
@ -1,14 +0,0 @@
|
||||
#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);
|
||||
MediocreSimpleStaticFileHandler() {};
|
||||
~MediocreSimpleStaticFileHandler() {};
|
||||
|
||||
};
|
@ -1,17 +0,0 @@
|
||||
#include "MediocreSimpleStaticFileHandler.H"
|
||||
|
||||
std::string
|
||||
MediocreSimpleStaticFileHandler::cleanpath (const char * const path)
|
||||
{
|
||||
//adds no security at all
|
||||
return "static/"+std::string(path);
|
||||
}
|
||||
|
||||
int
|
||||
MediocreSimpleStaticFileHandler::answer_pathreq(const char * const path,
|
||||
struct mg_connection *conn)
|
||||
{
|
||||
mg_send_file(conn,cleanpath(path).c_str());
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,9 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <mongoose.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
class StaticFileHandler
|
||||
{
|
||||
public:
|
||||
virtual int answer_pathreq(const char * const path,struct mg_connection *conn)=0;
|
||||
};
|
||||
public:
|
||||
int answer_pathreq(const char * const path, struct mg_connection *conn);
|
||||
std::string cleanpath(const char * const);
|
||||
StaticFileHandler() {};
|
||||
~StaticFileHandler() {};
|
||||
|
||||
private:
|
||||
std::string _cleanpath (const char * const path);
|
||||
|
||||
|
||||
};
|
||||
|
@ -0,0 +1,17 @@
|
||||
#include "StaticFileHandler.H"
|
||||
|
||||
std::string
|
||||
StaticFileHandler::_cleanpath (const char * const path)
|
||||
{
|
||||
//adds no security at all
|
||||
return "static/"+std::string(path);
|
||||
}
|
||||
|
||||
int
|
||||
StaticFileHandler::answer_pathreq(const char * const path,
|
||||
struct mg_connection *conn)
|
||||
{
|
||||
mg_send_file(conn,_cleanpath(path).c_str());
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include <mongoose.h>
|
||||
|
||||
class StaticFileHandler
|
||||
{
|
||||
public:
|
||||
virtual int answer_pathreq(const char * const path,struct mg_connection *conn)=0;
|
||||
};
|
||||
|
Loading…
Reference in new issue