use crate::prelude2::*;
pub use anyhow::Context as _;
use bson::oid::ObjectId;
#[derive(Debug, serde::Serialize, serde::Deserialize)]
pub struct SimpileMessage {
pub id: u32,
pub message: String,
}
pub async fn error2_1(request: HttpRequest) -> impl Responder {
let _ = tokio::fs::File::open("/tmp/asdfasdf")
.await
.context(Error2::GenericError("打开文件失败".into()))?;
request.json(200, R::ok(true))
}
pub async fn error2_2(
query: web::Query<HashMap<String, String>>,
request: HttpRequest,
) -> impl Responder {
let file_path = query
.get("file_path")
.context(Error2::InvalidParam("缺少参数: file_path".into()))?;
request.json(200, R::ok(file_path))
}
pub async fn error2_3(request: HttpRequest) -> impl Responder {
let _ = ObjectId::parse_str("1")?;
request.json(200, R::ok(true))
}