MongoController 提供 serve 函数来提供查询结果(作为光标)。我只想做一些不同于让服务返回 NotFound 的事情,比如发送一些其他默认文件。我想知道是否可以使用模式匹配来检查结果。签名是这样的:
/** Returns a future Result that serves the first matched file, or NotFound. */
def serve[T <: ReadFile[_ <: BSONValue], Structure, Reader[_], Writer[_]](gfs: GridFS[Structure, Reader, Writer], foundFile: Cursor[T], dispositionMode: String = CONTENT_DISPOSITION_ATTACHMENT)(implicit ec: ExecutionContext): Future[SimpleResult] = {