John Lowe
/
WebSockets2
Embedded WebSockets Experiment
Diff: HTTPRestHandler.h
- Revision:
- 0:6dee052a3fa4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HTTPRestHandler.h Tue Jul 26 05:30:53 2011 +0000 @@ -0,0 +1,38 @@ +#ifndef HTTP_REST_HANDLER_H +#define HTTP_REST_HANDLER_H + +#include "mbed.h" +#include "HTTPServer.h" +#include "string.h" + +#define RESP_LEN 1024 + +class HTTPRestData : public HTTPData { +public: + HTTPRestData() { + memset(response, 0, RESP_LEN); + }; + + char response[RESP_LEN]; +}; + +// HTTP handler for RESTful requests +class HTTPRestHandler : public HTTPHandler { +public: + HTTPRestHandler(const char *path) : HTTPHandler(path) { + printf("HTTPRestHandler: %s\n", path); + prefixLength= strlen(path); + } + +protected: + int prefixLength; + HTTPStatus doGet(char *resource, HTTPConnection *conn) const; + HTTPStatus doPost(char *resource, HTTPConnection *conn) const; + + virtual void reg(HTTPServer *server); + virtual HTTPStatus init(HTTPConnection *conn) const; + virtual HTTPHandle data(HTTPConnection *conn, void *data, int len) const; + virtual HTTPHandle send(HTTPConnection *conn, int maxData) const; +}; + +#endif