![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
1st Released
Dependencies: MbedJSONValue WIZnetInterface mbed
Fork of WIZwiki-REST by
Diff: HTTPServer.h
- Revision:
- 0:5886f525a4ad
- Child:
- 1:728e5b5c8dae
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HTTPServer.h Wed Mar 02 03:28:08 2016 +0000 @@ -0,0 +1,47 @@ +#ifndef HTTP_SERVER +#define HTTP_SERVER + +#include <map> + +#include "mbed.h" +#include <string> +#include "RequestHandler.h" +#include "EthernetInterface.h" + +typedef enum _HTTP_RESULT +{ + HTTP_INVALID_URI = -3, + HTTP_INVALID_DATA = -2, + HTTP_INVALID_HANDLE = -1, + HTTP_SUCCESS = 1 +}HTTP_RESULT; + + +static char HTTPBUF[1024] ={0,}; +static char rest_result[1024] = {0,}; + +class HTTPServer +{ + public : + + HTTPServer(); + virtual ~HTTPServer(); + + bool init(int port); + + void run(); + + void add_request_handler(char *name, RequestHandler* handler); + + private : + + HTTP_RESULT handle_request(char *buffer); + + TCPSocketServer socket; + std::map<char*, RequestHandler*, bool(*)(char*, char*)> handlers; + //char rest_result[2048]; + +}; + +#endif +