public HTTPResponse generateResponse( )
    {
        try {

            final DocumentController controller =
                ControllerFactory.getController(
                    request.getResource().substring(1)
                );

            switch (request.getMethod()) {
                case GET:
                    return handleGetRequest(controller);
                case POST:
                    return handlePostRequest(controller);
                case DELETE:
                    return handleDeleteRequest(controller);
                default:
                    return new HTTPResponse(
                        HTTPStatus.NOT_ALLOWED,
                        "Method not allowed: " + request.getMethod()
                    );
            }

        } catch (final BadRequestException bre) {
            return new HTTPResponse(
                HTTPStatus.BAD_REQ,
                "Invalid request: " + bre.getMessage()
            );
        } catch (final ControllerNotFoundException cnfe) {
            return new HTTPResponse(
                HTTPStatus.NOT_FOUND,
                "Path not found: /" + cnfe.getController()
            );
        } catch (final DocumentNotFoundException dnfe) {
            return new HTTPResponse(
                HTTPStatus.NOT_FOUND,
                "Document not found: " + dnfe.getUUID()
            );
        } catch (final ServerErrorException see) {
            return new HTTPResponse(
                HTTPStatus.INTERNAL_ERR,
                "Server error: " + see.getMessage()
            );
        }
    }