moved to mediocresimplestaticfilehandler

This commit is contained in:
john stone 2014-01-26 12:53:04 +01:00
parent b4337f73b2
commit 44df053023
5 changed files with 15 additions and 13 deletions

View File

@ -4,7 +4,7 @@ std::string
MediocreSimpleStaticFileHandler::cleanpath (const char * const path)
{
//adds no security at all
return std::string(path);
return "static/"+std::string(path);
}
int

View File

@ -3,7 +3,7 @@
#include <memory>
#include <mongoose.h>
#include "StaticFileHandler.H"
#include "MediocreSimpleStaticFileHandler.H"
class Routerin
{
@ -40,8 +40,8 @@ public:
}
private:
explicit Routerin();
std::unique_ptr<StaticFileHandler> sfh;
//bool hasInstance = false;
std::unique_ptr<MediocreSimpleStaticFileHandler> sfh;
bool hasInstance = false;
int event_request_route ( struct mg_event *event);
int event_newthread_route ( struct mg_event *event);

View File

@ -6,15 +6,16 @@ using std::strcmp;
#include "Foohash.H"
#include "Routerin.H"
#include "StaticFileHandler.H"
#include "UltraSimpleStaticFileHandler.H"
//#include "StaticFileHandler.H"
//#include "UltraSimpleStaticFileHandler.H"
using std::cout;
using std::endl;
Routerin::Routerin():
sfh( new UltraSimpleStaticFileHandler())
sfh( new MediocreSimpleStaticFileHandler())
{
cout << "Konstr Routering" << std::endl;
}
@ -57,10 +58,12 @@ int Routerin::event_request_route(struct mg_event *event){
break;
default:
std::cerr << "fallback ";
retval = rq_static((pntrstr),event);
retval = rq_static("illegalurl.htm",event);
};
}else{
std::cerr << "no blub! in " << __LINE__ << endl;
retval = rq_static("illegalurl.htm",event);
}
}
std::free(tmpstr);
@ -74,7 +77,6 @@ int Routerin::event_request_route(struct mg_event *event){
}
int Routerin::rq_static(char const * const reststr , struct mg_event *event)
{
std::cerr << " a static file is reqested!" << endl;

View File

@ -10,14 +10,12 @@ static const char * hello_world_html = u8R"HERE(
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<title></title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<h1 id="sharing-is-caring">Sharing is caring</h1>
<p>Hello World!</p>
<h2 id="it-works">It works</h2>
<!--«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»««»«»«»«»«»«»«»«»«»«»«»«»-->
<p>It seems like a working page has been served</p>
</body>
</html>)HERE";

View File

@ -135,12 +135,14 @@ int main(int argc, char **argv)
sa.sa_handler = signalhandler;
sigaction(SIGINT, &sa ,nullptr);
MongooseHandler m(args_info.port_arg);
MongooseHandler *m = new MongooseHandler(args_info.port_arg);
if (!args_info.daemonize_flag) {
while(1)
getchar();
}
delete m;
return 0;
}