![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
WIZwikiREST-io exercise code for WIZnet Academy
Dependencies: MbedJSONValue_v102 WIZnetInterface mbed
Fork of WIZwiki-REST-io_v103 by
RequestHandler.cpp
- Committer:
- joon874
- Date:
- 2016-03-02
- Revision:
- 0:5886f525a4ad
- Child:
- 1:728e5b5c8dae
File content as of revision 0:5886f525a4ad:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "RequestHandler.h" #include "MbedJSONValue.h" extern MbedJSONValue WIZwikiREST; void GetRequestHandler::handle(char* rest_uri, char *reply) { MbedJSONValue* tmpJson; char* tok; char* last; printf("GetRequestHandler():%s\r\n",rest_uri); if(!strcmp(rest_uri, "/")) { strcpy(reply, WIZwikiREST.serialize().c_str()); return; } tok = strtok_r(rest_uri+1, "/", &last); // 20160226 tmpJson = &WIZwikiREST; while(tok) { printf("tok = %s \r\n", tok); // Name if(tmpJson->size() > 0) tmpJson = &((*tmpJson)[tok]); else { tmpJson = 0; break; } tok = strtok_r(0, "/", &last); // 20160226 } if(tmpJson && tmpJson->size() > 0) { strcpy(reply, (*tmpJson).serialize().c_str()); } else { strcpy(reply, "{\"Result\" : \"No defined Resource\"}"); } return; } void PutRequestHandler::handle(char* rest_uri, char *reply) { } void DeleteRequestHandler::handle(char* rest_uri, char *reply) { }