diff --git a/rest/RESTCallBack.cpp b/rest/RESTCallBack.cpp index e6eca15..0b91fbb 100644 --- a/rest/RESTCallBack.cpp +++ b/rest/RESTCallBack.cpp @@ -1,4 +1,5 @@ #include +#include #include "RESTCallBack.h" RESTCallBack::~RESTCallBack() @@ -27,6 +28,16 @@ void RESTCallBack::getDescription(Dumais::JSON::JSON& json) RESTEngine::ResponseCode RESTCallBack::call(Dumais::JSON::JSON& json, const std::string& paramString, const std::string& dataString, std::smatch& matches) { RESTParameters params(paramString, mParamList); + // Let's check mandatory/required params + for (ParamMap::const_iterator it = mParamList.begin(); it != mParamList.end(); ++it) { + if (it->second.mRequired) { + if (params.getParam(it->first).empty()) { + std::cerr << "Missing mandatory parameter " << it->first << std::endl; + // todo : replace empty parameter value by default parameter value + } + } + } + RESTEngine::ResponseCode responseCode = RESTEngine::ResponseCode::OK; RESTContext context ={ json, diff --git a/rest/RESTEngine.h b/rest/RESTEngine.h index 823235f..7635780 100644 --- a/rest/RESTEngine.h +++ b/rest/RESTEngine.h @@ -26,8 +26,14 @@ class RESTEngine{ enum ResponseCode { OK, + Created, + Accepted, + BadRequest, + Forbidden, NotFound, - MethodNotAllowed + MethodNotAllowed, + NotImplemented, + ServiceUnavailable }; RESTEngine(); diff --git a/rest/RESTParameters.cpp b/rest/RESTParameters.cpp index 3297dc2..3afc258 100644 --- a/rest/RESTParameters.cpp +++ b/rest/RESTParameters.cpp @@ -43,6 +43,7 @@ RESTParameters::RESTParameters(const std::string ¶ms, const ParamMap ®ist break; } } + } RESTParameters::~RESTParameters(){