diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..b11a8e7 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,46 @@ +#include "N-Commands/KlingerHandler.h" +#include "N-Commands/RelationshipHandler.h" +#include <mongoose/Server.h> +#include <mongoose/WebController.h> + + +using namespace std; +using namespace Mongoose; + +class MyController : public WebController +{ +public: + void hello(Request &request, StreamResponse &response) + { + response << "Hello " << htmlEntities(request.get("name", "... what's your name ?")) << endl; + } + void klinger(Request &request, StreamResponse &response){ + KlingerHandler klinger; + klinger.onCall(request, response); + } + void relation(Request &request, StreamResponse &response){ + RelationshipHandler relation; + relation.onCall(request, response); + } + + void setup() + { + addRoute("GET", "/hello", MyController, hello); + addRoute("GET", "/klinger", MyController, klinger); + addRoute("GET", "/relation", MyController, relation); + } +}; + + +int main() +{ + MyController myController; + Server server(8080); + server.registerController(&myController); + + server.start(); + + while (1) { + MyController::sleep(10); + } +}
\ No newline at end of file |