refactoring s/MediocreSimple//, Vererbung muss weg!
This commit is contained in:
parent
44df053023
commit
6557a866ef
|
@ -13,9 +13,8 @@ siccc_SOURCES = \
|
||||||
src/Routerin.H \
|
src/Routerin.H \
|
||||||
src/Routerin.cc \
|
src/Routerin.cc \
|
||||||
src/sicmain.cc \
|
src/sicmain.cc \
|
||||||
src/MediocreSimpleStaticFileHandler.H \
|
src/StaticFileHandler.H \
|
||||||
src/MediocreSimpleStaticFileHandler.cc \
|
src/StaticFileHandler.cc \
|
||||||
src/UltraSimpleStaticFileHandler.cc \
|
|
||||||
mongoose/mongoose.c
|
mongoose/mongoose.c
|
||||||
siccc_CFLAGS =
|
siccc_CFLAGS =
|
||||||
siccc_CXXFLAGS = ${AM_CXXFLAGS} -DDEBUG -ggdb -I./mongoose/
|
siccc_CXXFLAGS = ${AM_CXXFLAGS} -DDEBUG -ggdb -I./mongoose/
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <mongoose.h>
|
#include <mongoose.h>
|
||||||
#include "MediocreSimpleStaticFileHandler.H"
|
#include "StaticFileHandler.H"
|
||||||
|
|
||||||
class Routerin
|
class Routerin
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,7 @@ public:
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
explicit Routerin();
|
explicit Routerin();
|
||||||
std::unique_ptr<MediocreSimpleStaticFileHandler> sfh;
|
std::unique_ptr<StaticFileHandler> sfh;
|
||||||
bool hasInstance = false;
|
bool hasInstance = false;
|
||||||
|
|
||||||
int event_request_route ( struct mg_event *event);
|
int event_request_route ( struct mg_event *event);
|
||||||
|
|
|
@ -6,16 +6,13 @@ using std::strcmp;
|
||||||
#include "Foohash.H"
|
#include "Foohash.H"
|
||||||
#include "Routerin.H"
|
#include "Routerin.H"
|
||||||
|
|
||||||
//#include "StaticFileHandler.H"
|
|
||||||
//#include "UltraSimpleStaticFileHandler.H"
|
|
||||||
|
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
|
|
||||||
Routerin::Routerin():
|
Routerin::Routerin():
|
||||||
sfh( new MediocreSimpleStaticFileHandler())
|
sfh( new StaticFileHandler())
|
||||||
{
|
{
|
||||||
cout << "Konstr Routering" << std::endl;
|
cout << "Konstr Routering" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,19 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <mongoose.h>
|
#include <mongoose.h>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class StaticFileHandler
|
class StaticFileHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual int answer_pathreq(const char * const path,struct mg_connection *conn)=0;
|
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