refactoring s/MediocreSimple//, Vererbung muss weg!

master
john stone 9 years ago
parent 44df053023
commit 6557a866ef

@ -13,9 +13,8 @@ siccc_SOURCES = \
src/Routerin.H \
src/Routerin.cc \
src/sicmain.cc \
src/MediocreSimpleStaticFileHandler.H \
src/MediocreSimpleStaticFileHandler.cc \
src/UltraSimpleStaticFileHandler.cc \
src/StaticFileHandler.H \
src/StaticFileHandler.cc \
mongoose/mongoose.c
siccc_CFLAGS =
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 <mongoose.h>
#include "MediocreSimpleStaticFileHandler.H"
#include "StaticFileHandler.H"
class Routerin
{
@ -40,7 +40,7 @@ public:
}
private:
explicit Routerin();
std::unique_ptr<MediocreSimpleStaticFileHandler> sfh;
std::unique_ptr<StaticFileHandler> sfh;
bool hasInstance = false;
int event_request_route ( struct mg_event *event);

@ -6,16 +6,13 @@ using std::strcmp;
#include "Foohash.H"
#include "Routerin.H"
//#include "StaticFileHandler.H"
//#include "UltraSimpleStaticFileHandler.H"
using std::cout;
using std::endl;
Routerin::Routerin():
sfh( new MediocreSimpleStaticFileHandler())
sfh( new StaticFileHandler())
{
cout << "Konstr Routering" << std::endl;
}

@ -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…
Cancel
Save