httpServer Library with Ethernet

Dependents:   Simple_HTTP_JSON HTTPWebServer-WIZwiki-W7500 HTTPWebServer-WIZwiki-W750023 WIZ750SR_test

Fork of httpServer by WIZnet

Committer:
justinkim
Date:
Wed Sep 02 02:03:22 2015 +0000
Revision:
2:dd293a10a772
Parent:
0:e59cc54df17c
network + analog in added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hjjeon 0:e59cc54df17c 1 /* FsHandler.h */
hjjeon 0:e59cc54df17c 2 /*
hjjeon 0:e59cc54df17c 3 Copyright (c) 2013 Henry Leinen (henry[dot]leinen [at] online [dot] de)
hjjeon 0:e59cc54df17c 4
hjjeon 0:e59cc54df17c 5 Permission is hereby granted, free of charge, to any person obtaining a copy
hjjeon 0:e59cc54df17c 6 of this software and associated documentation files (the "Software"), to deal
hjjeon 0:e59cc54df17c 7 in the Software without restriction, including without limitation the rights
hjjeon 0:e59cc54df17c 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
hjjeon 0:e59cc54df17c 9 copies of the Software, and to permit persons to whom the Software is
hjjeon 0:e59cc54df17c 10 furnished to do so, subject to the following conditions:
hjjeon 0:e59cc54df17c 11
hjjeon 0:e59cc54df17c 12 The above copyright notice and this permission notice shall be included in
hjjeon 0:e59cc54df17c 13 all copies or substantial portions of the Software.
hjjeon 0:e59cc54df17c 14
hjjeon 0:e59cc54df17c 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
hjjeon 0:e59cc54df17c 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
hjjeon 0:e59cc54df17c 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
hjjeon 0:e59cc54df17c 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
hjjeon 0:e59cc54df17c 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
hjjeon 0:e59cc54df17c 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
hjjeon 0:e59cc54df17c 21 THE SOFTWARE.
hjjeon 0:e59cc54df17c 22 */
hjjeon 0:e59cc54df17c 23 #ifndef __FSHANDLER_H__
hjjeon 0:e59cc54df17c 24 #define __FSHANDLER_H__
hjjeon 0:e59cc54df17c 25
hjjeon 0:e59cc54df17c 26 #include "mbed.h"
hjjeon 0:e59cc54df17c 27 #include "HTTPRequestHandler.h"
justinkim 2:dd293a10a772 28 #include "HTTPConnection.h"
justinkim 2:dd293a10a772 29 #include "EthernetInterface.h"
hjjeon 0:e59cc54df17c 30
hjjeon 0:e59cc54df17c 31 #include <map>
justinkim 2:dd293a10a772 32 #include <list>
hjjeon 0:e59cc54df17c 33 #include <string>
hjjeon 0:e59cc54df17c 34
hjjeon 0:e59cc54df17c 35 /** class HTTPFsRequestHandler serves requests with file-system objects
hjjeon 0:e59cc54df17c 36 */
hjjeon 0:e59cc54df17c 37 class HTTPFsRequestHandler : public HTTPRequestHandler
hjjeon 0:e59cc54df17c 38 {
hjjeon 0:e59cc54df17c 39 std::string m_rootPath;
hjjeon 0:e59cc54df17c 40 std::string m_localPath;
hjjeon 0:e59cc54df17c 41
hjjeon 0:e59cc54df17c 42 public:
justinkim 2:dd293a10a772 43
hjjeon 0:e59cc54df17c 44 /** constructor for HTTPFsRequestHandler object and stores the request related data locally.
hjjeon 0:e59cc54df17c 45 * the request handling will be initiated from within the constructor.
hjjeon 0:e59cc54df17c 46 * @param rootPath : The path under which the handler was registered.
hjjeon 0:e59cc54df17c 47 * @param localPath : The path which is relative to the registered file system root.
hjjeon 0:e59cc54df17c 48 * @param Msg : Message request information that comes with the request.
hjjeon 0:e59cc54df17c 49 * @param Tcp : The socket connection for communicating with the client.
hjjeon 0:e59cc54df17c 50 */
hjjeon 0:e59cc54df17c 51 HTTPFsRequestHandler(const char* rootPath, const char* localPath, HTTPConnection::HTTPMessage& Msg, TCPSocketConnection& Tcp);
hjjeon 0:e59cc54df17c 52
hjjeon 0:e59cc54df17c 53 /** Destructor
hjjeon 0:e59cc54df17c 54 */
hjjeon 0:e59cc54df17c 55 virtual ~HTTPFsRequestHandler();
hjjeon 0:e59cc54df17c 56
hjjeon 0:e59cc54df17c 57 /** static creation function for this object.
hjjeon 0:e59cc54df17c 58 */
hjjeon 0:e59cc54df17c 59 static inline HTTPRequestHandler* create(const char* rootPath, const char* localPath, HTTPConnection::HTTPMessage& msg, TCPSocketConnection& tcp) { return new HTTPFsRequestHandler(rootPath, localPath, msg, tcp); }
hjjeon 0:e59cc54df17c 60
hjjeon 0:e59cc54df17c 61 /** Handler function to serve GET requests
hjjeon 0:e59cc54df17c 62 */
hjjeon 0:e59cc54df17c 63 virtual int handleGetRequest();
hjjeon 0:e59cc54df17c 64
hjjeon 0:e59cc54df17c 65 /** Handler function to serve PUT requests
hjjeon 0:e59cc54df17c 66 */
hjjeon 0:e59cc54df17c 67 virtual int handlePutRequest();
hjjeon 0:e59cc54df17c 68
hjjeon 0:e59cc54df17c 69 /** Handler function to serve POST requests
hjjeon 0:e59cc54df17c 70 */
hjjeon 0:e59cc54df17c 71 virtual int handlePostRequest();
hjjeon 0:e59cc54df17c 72
hjjeon 0:e59cc54df17c 73 /** Map to register different file system types and associate them with different root paths
hjjeon 0:e59cc54df17c 74 */
hjjeon 0:e59cc54df17c 75 static std::map<const char*, const char*> m_fsMap;
hjjeon 0:e59cc54df17c 76
hjjeon 0:e59cc54df17c 77 /** static function to register a new file system type with a logical root path
hjjeon 0:e59cc54df17c 78 */
hjjeon 0:e59cc54df17c 79 static void mount(const char* requestPath, const char* localPath) { m_fsMap[requestPath] = localPath; }
hjjeon 0:e59cc54df17c 80
justinkim 2:dd293a10a772 81 //Test
justinkim 2:dd293a10a772 82 //static std::list<EthernetInterface> m_eth_list;
justinkim 2:dd293a10a772 83 static std::map<int, EthernetInterface*> m_eth_list;
justinkim 2:dd293a10a772 84 static void mount_eth(EthernetInterface* eth) { m_eth_list[0] = eth; }
justinkim 2:dd293a10a772 85
hjjeon 0:e59cc54df17c 86 /** Parse a uri string for uri file name and argument:value pairs
hjjeon 0:e59cc54df17c 87 */
hjjeon 0:e59cc54df17c 88 int parseUriArgs(string uri, map<string, string>& args);
hjjeon 0:e59cc54df17c 89
hjjeon 0:e59cc54df17c 90 uint32_t get_http_param_value(char* param_name);
hjjeon 0:e59cc54df17c 91 };
justinkim 2:dd293a10a772 92 #endif // __FSHANDLER_H__