private Response processRequest(DynamicDictionary parameters, RequestDetails requestDetails, 
            Func<DataModel, DataModel> dataStorageDelegate, Func<DataModel, RequestDetails, Response> responseDelegate)
        {
            var reqDataModel = new DataModel() { Path = Request.Url };
            var response = new Response();

            //If request have parameters - construct the Path and jsonQuery for the Model (i.e. "/movies/{id}")
            if (requestDetails.Parameters != null && requestDetails.Parameters.Any())
            {
                string lastParName = requestDetails.Parameters.Last();                                  //we are assuming that the last parameter in request path is an "id" 
                string lastParValue = parameters[lastParName].Value;                                    //and we can use this parameter name and value to compose json filter for our dataStorage        

                reqDataModel.Path = reqDataModel.Path.Remove(reqDataModel.Path.Length - lastParValue.Length);                     //remove last parameter value from the "/movies/101" => "/movies/", where 101 is some "id"
                reqDataModel.jsonQuery = $"{{\"{lastParName}\":\"{lastParValue}\"}}";                                             // {"lastParameterName":"lastParameterValue"}
            }

            
            JObject reqBobyJsonObj = null;
            string reqBodyJsonStr = Request.Body.AsString();

            //if request body contains Json - we need to validate (try to parse) this Json first
            if (!String.IsNullOrEmpty(reqBodyJsonStr))
            {
                try
                {
                    reqBobyJsonObj = JObject.Parse(reqBodyJsonStr);
                }
                catch (Exception ex)
                {
                    logger.Error($"Incorrect JSON in {requestDetails.Verb.ToUpper()} request!");
                    logger.Error(ex);

                    response = "Bad Request";
                    response.StatusCode = HttpStatusCode.BadRequest;
                    return response;                                        
                }            
            }

            //If request have an associated schema - we need to validate received Json (from request body) with this schema
            if (!String.IsNullOrEmpty(requestDetails.Schema)) { 
                JSchema jsonSchema = JSchema.Parse(requestDetails.Schema);
                if (!reqBobyJsonObj?.IsValid(jsonSchema) ?? true)
                {
                    logger.Error($"JSON in {requestDetails.Verb.ToUpper()} request does not match the RAML schema!!!");
                    response.StatusCode = HttpStatusCode.UnprocessableEntity;
                    return response;
                }
            }

            reqDataModel.jsonModel = reqBodyJsonStr;
            var resultingDataModel = dataStorageDelegate(reqDataModel);
            response = responseDelegate(resultingDataModel, requestDetails);
                
            return response;
        }
        private Response processResp(DataModel resultModel, RequestDetails requestDetails)
        {
            var response = new Response();
            if (resultModel.operationSuccesfull)
            {
                response.StatusCode = (HttpStatusCode)requestDetails.SuccessResponseCode;

                if (!String.IsNullOrEmpty(resultModel.jsonModel))
                {
                    response = resultModel.jsonModel;
                    response.ContentType = "application/json";
                }
            }
            else
            {
                response.StatusCode = HttpStatusCode.NotFound;
            };

            return response;
        }