public function handleQuery(HTTPRequest $request)
    {
        //get requested model(s) details
        $model = $request->param('ModelReference');

        $modelMap = Config::inst()->get(self::class, 'models');

        if (array_key_exists($model, $modelMap)) {
            $model = $modelMap[$model];
        }

        $id = $request->param('ID');
        $response = false;
        $queryParams = $this->parseQueryParameters($request->getVars());

        //validate Model name + store
        if ($model) {
            $model = $this->deSerializer->unformatName($model);
            if (!class_exists($model)) {
                return new RESTfulAPIError(400,
                    "Model does not exist. Received '$model'."
                );
            } else {
                //store requested model data and query data
                $this->requestedData['model'] = $model;
            }
        } else {
            //if model missing, stop + return blank object
            return new RESTfulAPIError(400,
                "Missing Model parameter."
            );
        }

        //check API access rules on model
        if (!RESTfulAPI::api_access_control($model, $request->httpMethod())) {
            return new RESTfulAPIError(403,
                "API access denied."
            );
        }

        //validate ID + store
        if (($request->isPUT() || $request->isDELETE()) && !is_numeric($id)) {
            return new RESTfulAPIError(400,
                "Invalid or missing ID. Received '$id'."
            );
        } elseif ($id !== null && !is_numeric($id)) {
            return new RESTfulAPIError(400,
                "Invalid ID. Received '$id'."
            );
        } else {
            $this->requestedData['id'] = $id;
        }

        //store query parameters
        if ($queryParams) {
            $this->requestedData['params'] = $queryParams;
        }

        //map HTTP word to module method
        switch ($request->httpMethod()) {
            case 'GET':
                return $this->findModel($model, $id, $queryParams, $request);
                break;
            case 'POST':
                return $this->createModel($model, $request);
                break;
            case 'PUT':
                return $this->updateModel($model, $id, $request);
                break;
            case 'DELETE':
                return $this->deleteModel($model, $id, $request);
                break;
            default:
                return new RESTfulAPIError(403,
                    "HTTP method mismatch."
                );
                break;
        }
    }