![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Revision 2016.05.03
Dependencies: MbedJSONValue1 WIZnetInterface mbed
Fork of WIZwiki-REST_mc by
HTTPServer.h@0:5886f525a4ad, 2016-03-02 (annotated)
- Committer:
- joon874
- Date:
- Wed Mar 02 03:28:08 2016 +0000
- Revision:
- 0:5886f525a4ad
- Child:
- 1:728e5b5c8dae
WIZwikiREST ver1 (Memory problem)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
joon874 | 0:5886f525a4ad | 1 | #ifndef HTTP_SERVER |
joon874 | 0:5886f525a4ad | 2 | #define HTTP_SERVER |
joon874 | 0:5886f525a4ad | 3 | |
joon874 | 0:5886f525a4ad | 4 | #include <map> |
joon874 | 0:5886f525a4ad | 5 | |
joon874 | 0:5886f525a4ad | 6 | #include "mbed.h" |
joon874 | 0:5886f525a4ad | 7 | #include <string> |
joon874 | 0:5886f525a4ad | 8 | #include "RequestHandler.h" |
joon874 | 0:5886f525a4ad | 9 | #include "EthernetInterface.h" |
joon874 | 0:5886f525a4ad | 10 | |
joon874 | 0:5886f525a4ad | 11 | typedef enum _HTTP_RESULT |
joon874 | 0:5886f525a4ad | 12 | { |
joon874 | 0:5886f525a4ad | 13 | HTTP_INVALID_URI = -3, |
joon874 | 0:5886f525a4ad | 14 | HTTP_INVALID_DATA = -2, |
joon874 | 0:5886f525a4ad | 15 | HTTP_INVALID_HANDLE = -1, |
joon874 | 0:5886f525a4ad | 16 | HTTP_SUCCESS = 1 |
joon874 | 0:5886f525a4ad | 17 | }HTTP_RESULT; |
joon874 | 0:5886f525a4ad | 18 | |
joon874 | 0:5886f525a4ad | 19 | |
joon874 | 0:5886f525a4ad | 20 | static char HTTPBUF[1024] ={0,}; |
joon874 | 0:5886f525a4ad | 21 | static char rest_result[1024] = {0,}; |
joon874 | 0:5886f525a4ad | 22 | |
joon874 | 0:5886f525a4ad | 23 | class HTTPServer |
joon874 | 0:5886f525a4ad | 24 | { |
joon874 | 0:5886f525a4ad | 25 | public : |
joon874 | 0:5886f525a4ad | 26 | |
joon874 | 0:5886f525a4ad | 27 | HTTPServer(); |
joon874 | 0:5886f525a4ad | 28 | virtual ~HTTPServer(); |
joon874 | 0:5886f525a4ad | 29 | |
joon874 | 0:5886f525a4ad | 30 | bool init(int port); |
joon874 | 0:5886f525a4ad | 31 | |
joon874 | 0:5886f525a4ad | 32 | void run(); |
joon874 | 0:5886f525a4ad | 33 | |
joon874 | 0:5886f525a4ad | 34 | void add_request_handler(char *name, RequestHandler* handler); |
joon874 | 0:5886f525a4ad | 35 | |
joon874 | 0:5886f525a4ad | 36 | private : |
joon874 | 0:5886f525a4ad | 37 | |
joon874 | 0:5886f525a4ad | 38 | HTTP_RESULT handle_request(char *buffer); |
joon874 | 0:5886f525a4ad | 39 | |
joon874 | 0:5886f525a4ad | 40 | TCPSocketServer socket; |
joon874 | 0:5886f525a4ad | 41 | std::map<char*, RequestHandler*, bool(*)(char*, char*)> handlers; |
joon874 | 0:5886f525a4ad | 42 | //char rest_result[2048]; |
joon874 | 0:5886f525a4ad | 43 | |
joon874 | 0:5886f525a4ad | 44 | }; |
joon874 | 0:5886f525a4ad | 45 | |
joon874 | 0:5886f525a4ad | 46 | #endif |
joon874 | 0:5886f525a4ad | 47 |