moved to mediocresimplestaticfilehandler
This commit is contained in:
parent
b4337f73b2
commit
44df053023
|
@ -4,7 +4,7 @@ std::string
|
||||||
MediocreSimpleStaticFileHandler::cleanpath (const char * const path)
|
MediocreSimpleStaticFileHandler::cleanpath (const char * const path)
|
||||||
{
|
{
|
||||||
//adds no security at all
|
//adds no security at all
|
||||||
return std::string(path);
|
return "static/"+std::string(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include <mongoose.h>
|
#include <mongoose.h>
|
||||||
#include "StaticFileHandler.H"
|
#include "MediocreSimpleStaticFileHandler.H"
|
||||||
|
|
||||||
class Routerin
|
class Routerin
|
||||||
{
|
{
|
||||||
|
@ -40,8 +40,8 @@ public:
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
explicit Routerin();
|
explicit Routerin();
|
||||||
std::unique_ptr<StaticFileHandler> sfh;
|
std::unique_ptr<MediocreSimpleStaticFileHandler> sfh;
|
||||||
//bool hasInstance = false;
|
bool hasInstance = false;
|
||||||
|
|
||||||
int event_request_route ( struct mg_event *event);
|
int event_request_route ( struct mg_event *event);
|
||||||
int event_newthread_route ( struct mg_event *event);
|
int event_newthread_route ( struct mg_event *event);
|
||||||
|
|
|
@ -6,15 +6,16 @@ using std::strcmp;
|
||||||
#include "Foohash.H"
|
#include "Foohash.H"
|
||||||
#include "Routerin.H"
|
#include "Routerin.H"
|
||||||
|
|
||||||
#include "StaticFileHandler.H"
|
//#include "StaticFileHandler.H"
|
||||||
#include "UltraSimpleStaticFileHandler.H"
|
//#include "UltraSimpleStaticFileHandler.H"
|
||||||
|
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
|
|
||||||
|
|
||||||
Routerin::Routerin():
|
Routerin::Routerin():
|
||||||
sfh( new UltraSimpleStaticFileHandler())
|
sfh( new MediocreSimpleStaticFileHandler())
|
||||||
{
|
{
|
||||||
cout << "Konstr Routering" << std::endl;
|
cout << "Konstr Routering" << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -57,10 +58,12 @@ int Routerin::event_request_route(struct mg_event *event){
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
std::cerr << "fallback ";
|
std::cerr << "fallback ";
|
||||||
retval = rq_static((pntrstr),event);
|
retval = rq_static("illegalurl.htm",event);
|
||||||
};
|
};
|
||||||
}else{
|
}else{
|
||||||
std::cerr << "no blub! in " << __LINE__ << endl;
|
std::cerr << "no blub! in " << __LINE__ << endl;
|
||||||
|
retval = rq_static("illegalurl.htm",event);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::free(tmpstr);
|
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)
|
int Routerin::rq_static(char const * const reststr , struct mg_event *event)
|
||||||
{
|
{
|
||||||
std::cerr << " a static file is reqested!" << endl;
|
std::cerr << " a static file is reqested!" << endl;
|
||||||
|
|
|
@ -10,14 +10,12 @@ static const char * hello_world_html = u8R"HERE(
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="generator" content="pandoc">
|
<meta name="generator" content="pandoc">
|
||||||
<title></title>
|
<title></title>
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1 id="sharing-is-caring">Sharing is caring</h1>
|
<h1 id="sharing-is-caring">Sharing is caring</h1>
|
||||||
<p>Hello World!</p>
|
<p>Hello World!</p>
|
||||||
<h2 id="it-works">It works</h2>
|
<h2 id="it-works">It works</h2>
|
||||||
|
<!--«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»««»«»«»«»«»«»«»«»«»«»«»«»-->
|
||||||
<p>It seems like a working page has been served</p>
|
<p>It seems like a working page has been served</p>
|
||||||
</body>
|
</body>
|
||||||
</html>)HERE";
|
</html>)HERE";
|
||||||
|
|
|
@ -135,12 +135,14 @@ int main(int argc, char **argv)
|
||||||
sa.sa_handler = signalhandler;
|
sa.sa_handler = signalhandler;
|
||||||
sigaction(SIGINT, &sa ,nullptr);
|
sigaction(SIGINT, &sa ,nullptr);
|
||||||
|
|
||||||
MongooseHandler m(args_info.port_arg);
|
MongooseHandler *m = new MongooseHandler(args_info.port_arg);
|
||||||
|
|
||||||
|
|
||||||
if (!args_info.daemonize_flag) {
|
if (!args_info.daemonize_flag) {
|
||||||
while(1)
|
while(1)
|
||||||
getchar();
|
getchar();
|
||||||
}
|
}
|
||||||
|
delete m;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue