WIZwikiREST ver1.0 (Memory problem)
Dependencies: MbedJSONValue WIZnetInterface mbed
RequestHandler.cpp
- Committer:
- joon874
- Date:
- 2016-03-02
- Revision:
- 0:5886f525a4ad
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)
{
}