Added POST call for Session::init for demo purposes

Signed-off-by: Louis Vallat <louis@louis-vallat.xyz>
This commit is contained in:
Louis Vallat 2021-10-16 22:20:46 +02:00
parent 0907126f09
commit 21fe4418f2
No known key found for this signature in database
GPG Key ID: 0C87282F76E61283

View File

@ -1,13 +1,21 @@
use hyper_tls::HttpsConnector; use hyper_tls::HttpsConnector;
use hyper::{Client, Uri}; use hyper::{Body, Client, Method, Request};
use std::str; use std::str;
use dotenv::dotenv;
#[tokio::main] #[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
dotenv().ok();
let https = HttpsConnector::new(); let https = HttpsConnector::new();
let client = Client::builder().build::<_, hyper::Body>(https); let client = Client::builder().build::<_, hyper::Body>(https);
let req = Request::builder()
.method(Method::POST)
.uri(dotenv::var("LYCHEE_ENDPOINT").unwrap())
.body(Body::empty())
.expect("error");
let res = client.request(req).await?;
let res = client.get(Uri::from_static("https://test.louis-vallat.xyz")).await?;
println!("{}", res.status().as_u16()); println!("{}", res.status().as_u16());
let buf = hyper::body::to_bytes(res).await?; let buf = hyper::body::to_bytes(res).await?;