public function index(HTTPRequest $request)
    {
        //check authentication if enabled
        if ($this->authenticator) {
            $policy = $this->config()->authentication_policy;
            $authALL = $policy === true;
            $authMethod = is_array($policy) && in_array($request->httpMethod(), $policy);

            if ($authALL || $authMethod) {
                $authResult = $this->authenticator->authenticate($request);

                if ($authResult instanceof RESTfulAPIError) {
                    //Authentication failed return error to client
                    return $this->error($authResult);
                }
            }
        }

        //pass control to query handler
        $data = $this->queryHandler->handleQuery($request);
        //catch + return errors
        if ($data instanceof RESTfulAPIError) {
            return $this->error($data);
        }

        //serialize response
        $json = $this->serializer->serialize($data);
        //catch + return errors
        if ($json instanceof RESTfulAPIError) {
            return $this->error($json);
        }

        //all is good reply normally
        return $this->answer($json);
    }