1pub mod index;
4pub mod market;
5
6use reqwest::header::{ACCEPT, HeaderMap, HeaderValue, REFERER, USER_AGENT};
7use std::{error, fmt};
8
9#[derive(Debug)]
11pub enum Error {
12 Request(reqwest::Error),
14}
15
16impl fmt::Display for Error {
17 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18 match self {
19 Self::Request(err) => write!(f, "{err}"),
20 }
21 }
22}
23
24impl error::Error for Error {
25 fn source(&self) -> Option<&(dyn error::Error + 'static)> {
26 match self {
27 Self::Request(err) => Some(err),
28 }
29 }
30}
31
32impl From<reqwest::Error> for Error {
33 fn from(err: reqwest::Error) -> Self {
34 Self::Request(err)
35 }
36}
37
38pub(crate) fn default_headers() -> HeaderMap {
39 let mut headers = HeaderMap::new();
40 headers.insert(
41 USER_AGENT,
42 HeaderValue::from_static(
43 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 \
44 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
45 ),
46 );
47 headers.insert(
48 REFERER,
49 HeaderValue::from_static("https://edition.cnn.com/"),
50 );
51 headers.insert(ACCEPT, HeaderValue::from_static("application/json"));
52 headers
53}