Some unknown work.
This commit is contained in:
parent
69914cbd59
commit
22b51559a6
1
FlowPoint.h
Normal file
1
FlowPoint.h
Normal file
@ -0,0 +1 @@
|
||||
#ifndef __FlowPoint_h__
|
19
HTTPEntryPoints.cpp
Normal file
19
HTTPEntryPoints.cpp
Normal file
@ -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;
|
||||
}
|
||||
|
||||
}
|
26
HTTPEntryPoints.h
Normal file
26
HTTPEntryPoints.h
Normal file
@ -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
|
@ -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<HTTPServer &>(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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
};
|
||||
|
BIN
HTTPServer
BIN
HTTPServer
Binary file not shown.
17
HTTPServer.cpp
Normal file
17
HTTPServer.cpp
Normal file
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
11
HTTPServer.h
11
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;
|
||||
|
7
View.cpp
Normal file
7
View.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "View.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
View::View() {}
|
||||
|
||||
}
|
17
View.h
Normal file
17
View.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef __View_h__
|
||||
#define __View_h__
|
||||
|
||||
#include "MString.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
class View : public coreutils::MString {
|
||||
|
||||
public:
|
||||
View();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
24
ViewCache.h
Normal file
24
ViewCache.h
Normal file
@ -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<coreutils::MString, coreutils::MString> views;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
24
ViewManager.cpp
Normal file
24
ViewManager.cpp
Normal file
@ -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) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
25
ViewManager.h
Normal file
25
ViewManager.h
Normal file
@ -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
|
@ -10,6 +10,8 @@ namespace http {
|
||||
|
||||
int page(HTTPParameters &p) override {
|
||||
|
||||
printf("path: %s", p.httpRequest.uriValues["path"].str().c_str());
|
||||
|
||||
p.data << "<html>"
|
||||
" <head>"
|
||||
" <link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\" />"
|
||||
@ -18,7 +20,7 @@ namespace http {
|
||||
" </head>"
|
||||
" <body ondragstart=\"return false;\" "
|
||||
" ondrop=\"return false;\" "
|
||||
" onLoad=\"getPage('/welcome','main');\">"
|
||||
" onLoad=\"getView('/welcome','main');\">"
|
||||
" <div id=\"main\">If you see this then something is wrong.</div>"
|
||||
" </body>"
|
||||
"</html>";
|
||||
|
@ -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);"
|
||||
" });"
|
||||
|
@ -27,7 +27,7 @@ namespace http {
|
||||
}
|
||||
|
||||
p.data << " <div style=\"background: #448; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\""
|
||||
" onmousedown=\"getPage('/editview/' + directory.get().getName(),'app1');\">"
|
||||
" onmousedown=\"getPage('/editview/testview1.view' + directory.get().getName(),'app1');\">"
|
||||
" <span>" << directory.get().getName() << "</span>"
|
||||
" </div>";
|
||||
directory.next();
|
||||
|
@ -1,34 +1,20 @@
|
||||
#include "__welcome.h"
|
||||
#include "__setupadmin.h"
|
||||
|
||||
namespace http {
|
||||
|
||||
int __welcome::page(HTTPParameters &p) {
|
||||
__welcome::__welcome() {
|
||||
|
||||
p.data << "<div class=\"adminheader\">"
|
||||
"Session Id: " << p.httpSession.getSessionId() << " <br>User: *ADMIN"
|
||||
"</div><br>";
|
||||
*this << "<div class=\"adminheader\">"
|
||||
"Session Id: $[__session_id] <br>User: *ADMIN"
|
||||
"</div><br>";
|
||||
"<div id=\"admin\" class=\"window\">"
|
||||
"<form name='admin'>"
|
||||
"<p>You have successfully set up a JETServer."
|
||||
"<br>The configuration has not yet been established for this web site.</p>"
|
||||
"<input type=\"button\" onmousedown=\"process('', 'admin', 'admin'); return true;\" name=\"button1\" value=\"Configure\">"
|
||||
"</form></div><br>";
|
||||
"<div id=\"app1\"></div><br>";
|
||||
|
||||
button1Click *click = new button1Click();
|
||||
coreutils::ZString button1_Click(p.actionList.addAction(click));
|
||||
|
||||
p.data << "<div id=\"admin\" class=\"window\">"
|
||||
"<form name='admin'>"
|
||||
"<p>You have successfully set up a JETServer."
|
||||
"<br>The configuration has not yet been established for this web site.</p>"
|
||||
"<input type=\"button\" onmousedown=\"process('" << button1_Click << "', 'admin', 'admin'); return true;\" name=\"button1\" value=\"Configure\">"
|
||||
"</form></div><br>";
|
||||
|
||||
p.data << "<div id=\"app1\"></div><br>";
|
||||
|
||||
p.httpRequest.response.addHeader(coreutils::IMFHeader("Content-Type", "text/html"));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool __welcome::button1Click::action(HTTPParameters &p) {
|
||||
__setupadmin setupadmin(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
15
__welcome.h
15
__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();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
2
main.cpp
2
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");
|
||||
|
16
static_flow.json
Normal file
16
static_flow.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"action": "default",
|
||||
"text": "Default Flow",
|
||||
"queues": [
|
||||
{
|
||||
"type": "XQ",
|
||||
"view": "default",
|
||||
"actions": [
|
||||
{
|
||||
"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user