feat: support ?json on file path (#686)

This commit is contained in:
sigoden
2026-04-23 18:39:26 +08:00
committed by GitHub
parent a118c1348e
commit a88a4ee630
2 changed files with 44 additions and 1 deletions
+16
View File
@@ -185,6 +185,22 @@ fn get_file(server: TestServer) -> Result<(), Error> {
Ok(())
}
#[rstest]
fn get_file_json(server: TestServer) -> Result<(), Error> {
let resp = reqwest::blocking::get(format!("{}index.html?json", server.url()))?;
assert_eq!(resp.status(), 200);
assert_eq!(
resp.headers().get("content-type").unwrap(),
"application/json"
);
let json: Value = serde_json::from_str(&resp.text()?).unwrap();
assert_eq!(json["name"], "index.html");
assert_eq!(json["path_type"], "File");
assert!(json["size"].as_u64().is_some());
assert!(json["mtime"].as_u64().is_some());
Ok(())
}
#[rstest]
fn head_file(server: TestServer) -> Result<(), Error> {
let resp = fetch!(b"HEAD", format!("{}index.html", server.url())).send()?;