ported HTTP-Server with W5500 Ethernet Shield

Dependencies:   W5500Interface mbed-rpc mbed

Fork of HTTP-Server by Francois Berder

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HTTPServer.h Source File

HTTPServer.h

00001 #ifndef HTTP_SERVER
00002 #define HTTP_SERVER
00003 
00004 #include <map>
00005 
00006 #include "mbed.h"
00007 #include "mbed_rpc.h"
00008 #include "RequestHandler.h"
00009 #include "Formatter.h"
00010 #include "EthernetInterface.h"
00011 #include "RPCCommand.h"
00012 
00013 
00014 class HTTPServer
00015 {
00016     public :
00017     
00018         HTTPServer(Formatter *f = new Formatter());
00019         virtual ~HTTPServer();
00020         
00021         bool init(int port);
00022 
00023         void run();
00024         
00025         void add_request_handler(char *name, RequestHandler* handler);
00026         
00027     private :
00028 
00029         void handle_request(char *buffer);
00030         
00031         TCPSocketServer socket;
00032         std::map<char*, RequestHandler*, bool(*)(char*, char*)> handlers;
00033         Formatter *formatter;
00034         char reply[RPC_MAX_STRING];
00035         RPCCommand command;
00036 };
00037 
00038 #endif
00039