Fork of HttpServer_snapshot_mbed-os library
Fork of HttpServer_snapshot_mbed-os by
FSHandler.h
00001 /* 00002 Permission is hereby granted, free of charge, to any person obtaining a copy 00003 of this software and associated documentation files (the "Software"), to deal 00004 in the Software without restriction, including without limitation the rights 00005 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00006 copies of the Software, and to permit persons to whom the Software is 00007 furnished to do so, subject to the following conditions: 00008 00009 The above copyright notice and this permission notice shall be included in 00010 all copies or substantial portions of the Software. 00011 00012 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00013 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00014 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00015 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00016 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00017 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00018 THE SOFTWARE. 00019 */ 00020 00021 #ifndef FS_HANDLER_H 00022 #define FS_HANDLER_H 00023 00024 #include "../HTTPRequestHandler.h" 00025 #include "mbed.h" 00026 #include <map> 00027 using std::map; 00028 00029 #include <string> 00030 using std::string; 00031 00032 class FSHandler : public HTTPRequestHandler 00033 { 00034 public: 00035 FSHandler(const char* rootPath, const char* path, TCPSocket* pTCPSocket); 00036 virtual ~FSHandler(); 00037 00038 static void mount(const string& fsPath, const string& rootPath); 00039 00040 //protected: 00041 static inline HTTPRequestHandler* inst(const char* rootPath, const char* path, TCPSocket* pTCPSocket) { return new FSHandler(rootPath, path, pTCPSocket); } //if we ever could do static virtual functions, this would be one 00042 00043 virtual void doGet(); 00044 virtual void doPost(); 00045 virtual void doHead(); 00046 00047 virtual void onReadable(); //Data has been read 00048 virtual void onWriteable(); //Data has been written & buf is free 00049 virtual void onClose(); //Connection is closing 00050 00051 private: 00052 FILE* m_fp; 00053 bool m_err404; 00054 static map<string,string> m_lFsPath; 00055 static Semaphore req_sem; 00056 }; 00057 00058 #endif 00059
Generated on Tue Jul 12 2022 21:12:22 by 1.7.2