lychee-client/src/main.rs

28 lines
739 B
Rust
Raw Normal View History

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