cod_client/
constructor.rs1use reqwest::{header, Client};
2
3use cod_types::token::Token;
4
5use crate::CodebergClient;
6
7impl CodebergClient {
8 pub fn new(token: &Token) -> anyhow::Result<Self> {
9 let Token(token) = token;
10 let mut headers = header::HeaderMap::new();
11 headers.insert(header::ACCEPT, "application/json".parse()?);
12 headers.insert(header::AUTHORIZATION, format!("Bearer {token}").parse()?);
13
14 let client = Client::builder().default_headers(headers).build()?;
15 Ok(Self(client))
16 }
17}