Add first work package for REST API implementation
[anna.git] / example / diameter / launcher / MyHandler.hpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #ifndef example_diameter_launcher_MyHandler_hpp
10 #define example_diameter_launcher_MyHandler_hpp
11
12 // Project
13 #include <anna/http/Response.hpp>
14 #include <anna/http/Handler.hpp>
15 #include <anna/json/json.hpp>
16
17
18 class MyHandler : public anna::http::Handler {
19 public:
20   MyHandler() : anna::http::Handler("http_converter::MyHandler") {
21     allocateResponse()->createHeader(anna::http::Header::Type::Date);
22   }
23
24 private:
25   void splitURI(const std::string &uri, std::string &operation, std::string & param1, std::string & param2) const;
26
27   void sendResponse(anna::comm::ClientSocket&, anna::http::Response *response);
28   bool doGET(const std::string &uri, std::string &response);
29   bool doPOST(const std::string &uri, const nlohmann::json &j, std::string &reponse);
30
31   void evRequest(anna::comm::ClientSocket&, const anna::http::Request& request) throw(anna::RuntimeException);
32   void evResponse(anna::comm::ClientSocket&, const anna::http::Response&) throw(anna::RuntimeException) {;}
33 };
34
35 #endif
36