Dependents:   SimpleLCDClock readCard2Twitter_http AnalogClock_StepperMotor_NTP ServoCamV1

Revision:
0:a2dd0ba6cd2d
Child:
1:7043cc0db03c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/services/http/server/HttpServer.h	Mon May 24 10:24:38 2010 +0000
@@ -0,0 +1,44 @@
+#ifndef HTTP_SERVER_H
+#define HTTP_SERVER_H
+
+class HttpRequestHandler;
+class HttpRequestDispatcher;
+
+#include "if/net/net.h"
+#include "HttpRequestHandler.h"
+#include "HttpRequestDispatcher.h"
+
+#include <string>
+using std::string;
+
+#include <map>
+using std::map;
+
+class HttpServer
+{
+public:
+  HttpServer();
+  ~HttpServer();
+
+  template<typename T>
+  void addHandler(const char* path) //Template decl in header
+  { m_lpHandlers[path] = &T::inst; }
+  
+  void bind(int port = 80);
+  
+private:
+  friend class HttpRequestDispatcher;
+
+  void onTcpSocketEvent(TcpSocketEvent e);
+  
+  TcpSocket* m_pTcpSocket;
+  map< string, HttpRequestHandler*(*)(const char*, const char*, TcpSocket*) > m_lpHandlers;
+
+};
+
+//Including handlers here for more convenience
+#include "impl/RpcHandler.h"
+#include "impl/FSHandler.h"
+#include "impl/SimpleHandler.h"
+
+#endif