2021-10-15 08:59:12 +02:00
|
|
|
use hyper_tls::HttpsConnector;
|
2021-10-16 22:20:46 +02:00
|
|
|
use hyper::{Body, Client, Method, Request};
|
2021-10-15 08:59:12 +02:00
|
|
|
use std::str;
|
2021-10-16 22:20:46 +02:00
|
|
|
use dotenv::dotenv;
|
2021-10-15 08:59:12 +02:00
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
2021-10-16 22:20:46 +02:00
|
|
|
dotenv().ok();
|
|
|
|
|
2021-10-15 08:59:12 +02:00
|
|
|
let https = HttpsConnector::new();
|
|
|
|
let client = Client::builder().build::<_, hyper::Body>(https);
|
2021-10-16 22:20:46 +02:00
|
|
|
let req = Request::builder()
|
|
|
|
.method(Method::POST)
|
2021-10-17 10:19:36 +02:00
|
|
|
.uri(dotenv::var("LYCHEE_ENDPOINT").unwrap() + "/api/Session::init")
|
2021-10-16 22:20:46 +02:00
|
|
|
.body(Body::empty())
|
|
|
|
.expect("error");
|
|
|
|
let res = client.request(req).await?;
|
2021-10-15 08:59:12 +02:00
|
|
|
|
|
|
|
println!("{}", res.status().as_u16());
|
|
|
|
|
|
|
|
let buf = hyper::body::to_bytes(res).await?;
|
|
|
|
let s = str::from_utf8(&buf).unwrap();
|
|
|
|
println!("{:?}", s);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
2021-10-17 10:17:34 +02:00
|
|
|
|