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