diff --git a/FlowPoint.h b/FlowPoint.h new file mode 100644 index 0000000..8183cc2 --- /dev/null +++ b/FlowPoint.h @@ -0,0 +1 @@ +#ifndef __FlowPoint_h__ diff --git a/HTTPEntryPoints.cpp b/HTTPEntryPoints.cpp new file mode 100644 index 0000000..179e536 --- /dev/null +++ b/HTTPEntryPoints.cpp @@ -0,0 +1,19 @@ +#include "HTTPEntryPoints.h" +#include "ZString.h" +#include "IMFFormData.h" +#include "Exception.h" +#include "Log.h" + +namespace http { + + HTTPEntryPoints::HTTPEntryPoints() : index("testview1"), notfound("testview1") {} + + coreutils::ZString HTTPEntryPoints::getView(coreutils::ZString &uri) { + if(uri == "/") { + return index; + } + + return notfound; + } + +} diff --git a/HTTPEntryPoints.h b/HTTPEntryPoints.h new file mode 100644 index 0000000..b0906d1 --- /dev/null +++ b/HTTPEntryPoints.h @@ -0,0 +1,26 @@ +#ifndef __HTTPEntryPoints_h__ +#define __HTTPEntryPoints_h__ + +#include "Command.h" +#include "TCPSession.h" +#include "Log.h" +#include "IMFMessage.h" +#include "HTTPRequest.h" + +namespace http { + + class HTTPEntryPoints { + + public: + HTTPEntryPoints(); + coreutils::ZString getView(coreutils::ZString &uri); + + private: + coreutils::ZString index; + coreutils::ZString notfound; + + }; + +} + +#endif diff --git a/HTTPGETHandler.cpp b/HTTPGETHandler.cpp index 0ce8790..c5adf1a 100644 --- a/HTTPGETHandler.cpp +++ b/HTTPGETHandler.cpp @@ -20,6 +20,15 @@ namespace http { HTTPParameters p(httpRequest, session, *httpSession, content, ((HTTPServer &)session.server).actionList); + // TODO: What should we do if we receive a request on a GET and there is a session variable? + // If its an entry point then is it an image or link to a downloadable content that was issued + // by the page? Referer must point to the proper entity. + + entryPoints.processCommand(p); + + // TODO: Right here we need to do a lookup to the entry table. File requests need an entry point URL to serve. + // TODO: Allow entry points to specify pages in the page cache or do we treat pages as automatic entry points. + try { static_cast(session.server).pageList.processRequest(p); httpRequest.response.setCode("200"); @@ -31,7 +40,7 @@ namespace http { } session.out << httpRequest.response.getResponse(content).str(); -// coreutils::Log(coreutils::LOG_DEBUG_1) << session.out.str(); + return true; } diff --git a/HTTPGETHandler.h b/HTTPGETHandler.h index 71a091a..c977617 100644 --- a/HTTPGETHandler.h +++ b/HTTPGETHandler.h @@ -6,6 +6,7 @@ #include "Log.h" #include "IMFMessage.h" #include "HTTPRequest.h" +#include "HTTPEntryPoints.h" namespace http { @@ -17,7 +18,7 @@ namespace http { private: HTTPRequest *httpRequest = NULL; bool processHTTPRequest(core::TCPSession &session); - + HTTPEntryPoints entryPoints; }; } diff --git a/HTTPPageList.h b/HTTPPageList.h index 3fca899..2509e84 100644 --- a/HTTPPageList.h +++ b/HTTPPageList.h @@ -5,16 +5,8 @@ # include "ZString.h" # include "__index.h" # include "__script.h" -# include "__editview.h" -# include "__editview_js.h" # include "__style.h" -# include "__entrypoints.h" # include "__favicon_ico.h" -# include "__welcome.h" -# include "__viewlist.h" -# include "__workflow.h" -# include "__workflow_js.h" -# include "__addview.h" # include "_image.h" namespace http { @@ -25,17 +17,10 @@ namespace http { HTTPPageList() { add(index, "/"); add(script, "/script"); - add(editview, "/editview/{view_name}"); - add(editview_js, "/__editview_js"); add(style, "/style"); - add(entrypoints, "/entrypoints"); add(favicon_ico, "/favicon.ico"); - add(welcome, "/welcome"); - add(viewlist, "/viewlist"); - add(workflow, "/workflow"); - add(workflow_js, "/__workflow_js"); add(image, "/image/{image_name}"); - add(addview, "/addview"); + add(index, "/{path}"); } bool processRequest(HTTPParameters &p); @@ -53,15 +38,7 @@ namespace http { __index index; __script script; __style style; - __editview editview; - __editview_js editview_js; - __entrypoints entrypoints; __favicon_ico favicon_ico; - __welcome welcome; - __viewlist viewlist; - __workflow workflow; - __workflow_js workflow_js; - __addview addview; _image image; }; diff --git a/HTTPServer b/HTTPServer deleted file mode 100755 index 1ca9b7d..0000000 Binary files a/HTTPServer and /dev/null differ diff --git a/HTTPServer.cpp b/HTTPServer.cpp new file mode 100644 index 0000000..e4eb784 --- /dev/null +++ b/HTTPServer.cpp @@ -0,0 +1,17 @@ +#include "HTTPServer.h" + +namespace http { + + HTTPServer::HTTPServer(core::EPoll &ePoll, core::IPAddress ipAddress, HTTPSessions &httpSessions) + : TCPServer(ePoll, ipAddress), httpSessions(httpSessions) { + commands.add(getHandler, "GET"); + commands.add(postHandler, "POST"); + commands.add(putHandler, "PUT"); + } + + core::TCPSession * HTTPServer::getSocketAccept(core::EPoll &epoll) { + return new HTTPConnection(ePoll, *this); + } + +} + diff --git a/HTTPServer.h b/HTTPServer.h index 35c08e8..10953f2 100644 --- a/HTTPServer.h +++ b/HTTPServer.h @@ -17,16 +17,9 @@ namespace http { class HTTPServer : public core::TCPServer { public: - HTTPServer(core::EPoll &ePoll, core::IPAddress ipAddress, HTTPSessions &httpSessions) - : TCPServer(ePoll, ipAddress), httpSessions(httpSessions) { - commands.add(getHandler, "GET"); - commands.add(postHandler, "POST"); - commands.add(putHandler, "PUT"); - } + HTTPServer(core::EPoll &ePoll, core::IPAddress ipAddress, HTTPSessions &httpSessions); - core::TCPSession * getSocketAccept(core::EPoll &epoll) override { - return new HTTPConnection(ePoll, *this); - } + core::TCPSession * getSocketAccept(core::EPoll &epoll) override; HTTPSessions &httpSessions; HTTPPageList pageList; diff --git a/View.cpp b/View.cpp new file mode 100644 index 0000000..e5403b4 --- /dev/null +++ b/View.cpp @@ -0,0 +1,7 @@ +#include "View.h" + +namespace http { + + View::View() {} + +} diff --git a/View.h b/View.h new file mode 100644 index 0000000..82f182b --- /dev/null +++ b/View.h @@ -0,0 +1,17 @@ +#ifndef __View_h__ +#define __View_h__ + +#include "MString.h" + +namespace http { + + class View : public coreutils::MString { + + public: + View(); + + }; + +} + +#endif \ No newline at end of file diff --git a/ViewCache.h b/ViewCache.h new file mode 100644 index 0000000..1d60969 --- /dev/null +++ b/ViewCache.h @@ -0,0 +1,24 @@ +#ifndef __ViewCache_h__ +# define __ViewCache_h__ + +#include "HTTPParameters.h" +#include "MString.h" + +namespace http { + + class ViewCache { + + public: + ViewCache(); + virtual ~ViewCache(); + + bool getView(HTTPParameters &p); + + private: + std::map views; + + }; + +} + +#endif diff --git a/ViewManager.cpp b/ViewManager.cpp new file mode 100644 index 0000000..af2c956 --- /dev/null +++ b/ViewManager.cpp @@ -0,0 +1,24 @@ +#include "ViewManager.h" + +namespace http { + + ViewManager::ViewManager() {} + + ViewManager::~ViewManager() {} + + bool ViewManager::addView(coreutils::MString name, View view) { + } + + bool ViewManager::getView(HTTPParameters &p) { + } + + bool ViewManager::changeView(coreutile::MString name, View view) { + } + + bool ViewManager::deleteView(coreutils::MString name) { + } + +} + + + \ No newline at end of file diff --git a/ViewManager.h b/ViewManager.h new file mode 100644 index 0000000..17a0860 --- /dev/null +++ b/ViewManager.h @@ -0,0 +1,25 @@ +#ifndef __ViewManager_h__ +# define __ViewManager_h__ + +#include "HTTPParameters.h" +#include "MString.h" +#include "View.h" + +namespace http { + + class ViewManager { + + public: + ViewManager(); + virtual ~ViewManager(); + + bool addView(coreutils::MString name, View view); + bool getView(HTTPParameters &p); + bool changeView(coreutils::MString name, View view); + bool deleteView(coreutils::MString name); + + }; + +} + +#endif diff --git a/__index.h b/__index.h index 1331fe6..9b86981 100644 --- a/__index.h +++ b/__index.h @@ -10,6 +10,8 @@ namespace http { int page(HTTPParameters &p) override { + printf("path: %s", p.httpRequest.uriValues["path"].str().c_str()); + p.data << "" " " " " @@ -18,7 +20,7 @@ namespace http { " " " " + " onLoad=\"getView('/welcome','main');\">" "
If you see this then something is wrong.
" " " ""; diff --git a/__script.h b/__script.h index 888ab7a..c151cbc 100644 --- a/__script.h +++ b/__script.h @@ -18,7 +18,7 @@ namespace http { " server.open(type, url, true);" " server.send(formData);" "}" - "function getPage(url, receiver) {" + "function getView(url, receiver) {" " serverSend(url, \"GET\", receiver, null, function(data, receiver) {" " insertAndExecute(receiver, data);" " });" diff --git a/__viewlist.h b/__viewlist.h index 8fc9ebb..7270b6e 100644 --- a/__viewlist.h +++ b/__viewlist.h @@ -27,7 +27,7 @@ namespace http { } p.data << "
" + " onmousedown=\"getPage('/editview/testview1.view' + directory.get().getName(),'app1');\">" " " << directory.get().getName() << "" "
"; directory.next(); diff --git a/__welcome.cpp b/__welcome.cpp index e5c9e21..388fd94 100644 --- a/__welcome.cpp +++ b/__welcome.cpp @@ -1,34 +1,20 @@ #include "__welcome.h" -#include "__setupadmin.h" namespace http { - int __welcome::page(HTTPParameters &p) { + __welcome::__welcome() { - p.data << "
" - "Session Id: " << p.httpSession.getSessionId() << "
User: *ADMIN" - "

"; + *this << "
" + "Session Id: $[__session_id]
User: *ADMIN" + "

"; + "
" + "
" + "

You have successfully set up a JETServer." + "
The configuration has not yet been established for this web site.

" + "" + "

"; + "

"; - button1Click *click = new button1Click(); - coreutils::ZString button1_Click(p.actionList.addAction(click)); - - p.data << "
" - "
" - "

You have successfully set up a JETServer." - "
The configuration has not yet been established for this web site.

" - "" - "

"; - - p.data << "

"; - - p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "text/html")); - - return 1; - } - - bool __welcome::button1Click::action(HTTPParameters &p) { - __setupadmin setupadmin(p); - return true; } } diff --git a/__welcome.h b/__welcome.h index f408072..078807b 100644 --- a/__welcome.h +++ b/__welcome.h @@ -1,22 +1,15 @@ #ifndef ____welcome_h__ #define ____welcome_h__ -#include "FlowAction.h" -#include "HTTPPage.h" +#include "View.h" namespace http { - class __welcome : public HTTPPage { + class __welcome : public View { public: - int page(HTTPParameters &p) override; - - class button1Click : public FlowAction { - - public: - bool action(HTTPParameters &p) override; - - }; + __welcome(); + }; } diff --git a/main.cpp b/main.cpp index dc5737b..e353f6b 100644 --- a/main.cpp +++ b/main.cpp @@ -20,7 +20,7 @@ int main(int argc, char **argv) { http::HTTPSessions httpSessions; - http::HTTPServer http(ePoll, core::IPAddress(ipAddress, 8080), httpSessions); + http::HTTPServer http(ePoll, core::IPAddress(ipAddress, 80), httpSessions); core::ConsoleServer console(ePoll, core::IPAddress(ipAddress, 1027)); console.commands.add(ePoll, "threads"); diff --git a/static_flow.json b/static_flow.json new file mode 100644 index 0000000..feaf2e5 --- /dev/null +++ b/static_flow.json @@ -0,0 +1,16 @@ +{ + "action": "default", + "text": "Default Flow", + "queues": [ + { + "type": "XQ", + "view": "default", + "actions": [ + { + " + } + ] + } + + ] +} \ No newline at end of file