protected function provides($mimetype)
    {
        if (count($this->request->getAccept()) == 0) return 0;
        $pos = array_search($mimetype, $this->request->getAccept());
        if ($pos === FALSE) {
            if (in_array('*/*', $this->request->getAccept())) {
                return 0;
            } else {
                throw new NotAcceptableException('No matching method for response type "'.join(', ', $this->request->getAccept()).'"');
            }
        } else {
            $this->after(function ($response) use ($mimetype) {
                $response->contentType = $mimetype;
            });

            return count($this->request->getAccept()) - $pos;
        }
    }