1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use fs;
use path;
/// Stores the HTTP response body on disk as an HTML file.
///
/// This function takes the storage path, the URL from which the response was fetched,
/// and the response body, and writes the body to a file located in the specified
/// storage path. The file name is generated based on the URL's path. If the URL path
/// is empty, the file is named `index.html`, otherwise, the file name is derived
/// from the URL path with `.html` as its extension. Any necessary directories in the
/// path are created if they don't already exist.
///
/// # Arguments
///
/// * `storage_path` - A reference to the target directory where the response will be stored.
/// This should be passed as an `&Path` (not `&PathBuf` for efficiency).
/// * `url` - A reference to the URL object representing the source of the response.
/// * `body` - The response body content that will be written to the file.
///
/// # Panics
///
/// This function will panic if it fails to write the file to the specified path.
pub async