public function options(EventInterface $event) {
        $request = $event->getRequest();
        $response = $event->getResponse();
        $origin = $request->headers->get('Origin');

        // This is an OPTIONS request, send 204 since no more content will follow
        $response->setStatusCode(204);

        // Vary on Origin to prevent caching allowed/disallowed requests
        $event->getResponse()->setVary('Origin', false);

        // Fall back if the passed origin is not allowed
        if (!$origin || !$this->originIsAllowed($origin)) {
            return;
        }

        $resource = (string) $request->getRoute();

        $allowedMethods = ['OPTIONS'];

        if (isset($this->params['allowedMethods'][$resource])) {
            $allowedMethods = array_merge($allowedMethods, $this->params['allowedMethods'][$resource]);
        }

        $allowedHeaders = ['Content-Type', 'Accept'];

        $requestHeaders = $request->headers->get('Access-Control-Request-Headers', '');
        $requestHeaders = array_map('trim', explode(',', $requestHeaders));

        foreach ($requestHeaders as $header) {
            if (strpos($header, 'x-imbo') === 0) {
                $allowedHeaders[] = implode('-', array_map('ucfirst', explode('-', $header)));;
            }
        }

        $response->headers->add([
            'Access-Control-Allow-Origin' => $origin,
            'Access-Control-Allow-Methods' => implode(', ', $allowedMethods),
            'Access-Control-Allow-Headers' => implode(', ', $allowedHeaders),
            'Access-Control-Max-Age' => (int) $this->params['maxAge'],
        ]);

        // Since this is an OPTIONS-request, there is no need for further parsing
        $event->stopPropagation();
    }