diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/apiHandler.cpp | 15 | ||||
-rw-r--r-- | src/apiHandler.h | 22 | ||||
-rw-r--r-- | src/server.cpp | 9 |
3 files changed, 42 insertions, 4 deletions
diff --git a/src/apiHandler.cpp b/src/apiHandler.cpp new file mode 100644 index 0000000..231fd6c --- /dev/null +++ b/src/apiHandler.cpp @@ -0,0 +1,15 @@ +#include "apiHandler.h" + +using namespace std; + +apiHandler::apiHandler(struct mg_connection *conn) { + MyConnection = conn; +} + +apiHandler::~apiHandler(void) { } + +int apiHandler::processRequest(void) { + + return MG_FALSE; + +} diff --git a/src/apiHandler.h b/src/apiHandler.h new file mode 100644 index 0000000..6909fdd --- /dev/null +++ b/src/apiHandler.h @@ -0,0 +1,22 @@ +#ifndef _APIHANDLER_ +#define APIHANDLER + +#include <iostream> +#include <string> +#include <vector> +#include <regex> +#include "mongoose.h" + +using namespace std; + +class apiHandler { +private: + struct mg_connection *MyConnection; + +public: + apiHandler(struct mg_connection*); + ~apiHandler(void); + int processRequest(); +}; + +#endif diff --git a/src/server.cpp b/src/server.cpp index 222e8ea..3efb51d 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1,16 +1,16 @@ #include <iostream> #include <string> #include "mongoose.h" +#include "apiHandler.h" using namespace std; int event_handler(struct mg_connection *conn, enum mg_event ev) { + apiHandler MyApiHandler(conn); + switch (ev) { case MG_AUTH: return MG_TRUE; - case MG_REQUEST: - if (conn->uri) { - cout<<conn->request_method<<" "<<conn->uri<<endl; - } else return MG_FALSE; + case MG_REQUEST: return MyApiHandler.processRequest(); default: return MG_FALSE; } } @@ -21,6 +21,7 @@ int main(int argc, char **argv) { struct mg_server *server = mg_create_server(NULL, event_handler); mg_set_option(server, "document_root", "./www/"); + mg_set_option(server, "enable_directory_listing", "no"); mg_set_option(server, "listening_port", server_port.c_str()); cout<<"Staring server on port "<<server_port<<"."<<endl; |