private function executePreInterceptor($preInterceptor, Request $request, Response $response)
    {
        if (is_callable($preInterceptor)) {
            return $preInterceptor($request, $response);
        }

        if ($preInterceptor instanceof PreInterceptor) {
            return $preInterceptor->preProcess($request, $response);
        }

        $instance = $this->injector->getInstance($preInterceptor);
        if (!($instance instanceof PreInterceptor)) {
            $response->write(
                    $response->internalServerError(
                            'Configured pre interceptor ' . $preInterceptor
                            . ' is not an instance of ' . PreInterceptor::class
                    )
            );
            return false;
        }

        return $instance->preProcess($request, $response);
    }