Team E1
Fork of HTTPServer by
Handler/RpcHandler.h@19:e80980c149eb, 2016-02-01 (annotated)
- Committer:
- VervoortRaf
- Date:
- Mon Feb 01 10:25:06 2016 +0000
- Revision:
- 19:e80980c149eb
- Parent:
- 5:dc88012caef1
Smart remote school project Team E1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
leihen | 5:dc88012caef1 | 1 | /* RpcHandler.h */ |
leihen | 5:dc88012caef1 | 2 | /* |
leihen | 5:dc88012caef1 | 3 | Copyright (c) 2013 Henry Leinen (henry[dot]leinen [at] online [dot] de) |
leihen | 5:dc88012caef1 | 4 | |
leihen | 5:dc88012caef1 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy |
leihen | 5:dc88012caef1 | 6 | of this software and associated documentation files (the "Software"), to deal |
leihen | 5:dc88012caef1 | 7 | in the Software without restriction, including without limitation the rights |
leihen | 5:dc88012caef1 | 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
leihen | 5:dc88012caef1 | 9 | copies of the Software, and to permit persons to whom the Software is |
leihen | 5:dc88012caef1 | 10 | furnished to do so, subject to the following conditions: |
leihen | 5:dc88012caef1 | 11 | |
leihen | 5:dc88012caef1 | 12 | The above copyright notice and this permission notice shall be included in |
leihen | 5:dc88012caef1 | 13 | all copies or substantial portions of the Software. |
leihen | 5:dc88012caef1 | 14 | |
leihen | 5:dc88012caef1 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
leihen | 5:dc88012caef1 | 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
leihen | 5:dc88012caef1 | 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
leihen | 5:dc88012caef1 | 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
leihen | 5:dc88012caef1 | 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
leihen | 5:dc88012caef1 | 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
leihen | 5:dc88012caef1 | 21 | THE SOFTWARE. |
leihen | 5:dc88012caef1 | 22 | */ |
leihen | 5:dc88012caef1 | 23 | #ifndef __RPCHANDLER_H__ |
leihen | 5:dc88012caef1 | 24 | #define __RPCHANDLER_H__ |
leihen | 5:dc88012caef1 | 25 | |
leihen | 5:dc88012caef1 | 26 | #include "mbed.h" |
leihen | 5:dc88012caef1 | 27 | #include "HTTPRequestHandler.h" |
leihen | 5:dc88012caef1 | 28 | |
leihen | 5:dc88012caef1 | 29 | class HTTPRpcRequestHandler : public HTTPRequestHandler |
leihen | 5:dc88012caef1 | 30 | { |
leihen | 5:dc88012caef1 | 31 | std::string m_rootPath; |
leihen | 5:dc88012caef1 | 32 | std::string m_localPath; |
leihen | 5:dc88012caef1 | 33 | |
leihen | 5:dc88012caef1 | 34 | public: |
leihen | 5:dc88012caef1 | 35 | /** constructor for HTTPRpcRequestHandler object and stores the request related data locally. |
leihen | 5:dc88012caef1 | 36 | * the request handling will be initiated from within the constructor. |
leihen | 5:dc88012caef1 | 37 | * @param rootPath : The path under which the handler was registered. |
leihen | 5:dc88012caef1 | 38 | * @param localPath : The path which is relative to the registered file system root. |
leihen | 5:dc88012caef1 | 39 | * @param Msg : Message request information that comes with the request. |
leihen | 5:dc88012caef1 | 40 | * @param Tcp : The socket connection for communicating with the client. |
leihen | 5:dc88012caef1 | 41 | */ |
leihen | 5:dc88012caef1 | 42 | HTTPRpcRequestHandler(const char* rootPath, const char* localPath, HTTPConnection::HTTPMessage& Msg, TCPSocketConnection& Tcp); |
leihen | 5:dc88012caef1 | 43 | |
leihen | 5:dc88012caef1 | 44 | /** Destructor |
leihen | 5:dc88012caef1 | 45 | */ |
leihen | 5:dc88012caef1 | 46 | virtual ~HTTPRpcRequestHandler(); |
leihen | 5:dc88012caef1 | 47 | |
leihen | 5:dc88012caef1 | 48 | /** static creation function for this object. |
leihen | 5:dc88012caef1 | 49 | */ |
leihen | 5:dc88012caef1 | 50 | static inline HTTPRequestHandler* create(const char* rootPath, const char* localPath, HTTPConnection::HTTPMessage& msg, TCPSocketConnection& tcp) { return new HTTPRpcRequestHandler(rootPath, localPath, msg, tcp); } |
leihen | 5:dc88012caef1 | 51 | |
leihen | 5:dc88012caef1 | 52 | /** Handler function to serve GET requests |
leihen | 5:dc88012caef1 | 53 | */ |
leihen | 5:dc88012caef1 | 54 | virtual int handleGetRequest(); |
leihen | 5:dc88012caef1 | 55 | |
leihen | 5:dc88012caef1 | 56 | /** Handler function to serve PUT requests |
leihen | 5:dc88012caef1 | 57 | */ |
leihen | 5:dc88012caef1 | 58 | virtual int handlePutRequest(); |
leihen | 5:dc88012caef1 | 59 | |
leihen | 5:dc88012caef1 | 60 | /** Handler function to serve POST requests |
leihen | 5:dc88012caef1 | 61 | */ |
leihen | 5:dc88012caef1 | 62 | virtual int handlePostRequest(); |
leihen | 5:dc88012caef1 | 63 | |
leihen | 5:dc88012caef1 | 64 | /** Parse a uri string for uri file name and argument:value pairs |
leihen | 5:dc88012caef1 | 65 | */ |
leihen | 5:dc88012caef1 | 66 | // int parseUriArgs(string uri, string map<string, string>& args); |
leihen | 5:dc88012caef1 | 67 | }; |
leihen | 5:dc88012caef1 | 68 | #endif // __RPCHANDLER_H__ |