zed/crates/live_kit_server/src/api.rs

37 lines
1,009 B
Rust
Raw Normal View History

2022-10-14 15:00:38 +00:00
use crate::token;
use hyper::{client::HttpConnector, Request, Uri};
pub struct Client {
http: hyper::Client<HttpConnector>,
uri: Uri,
key: String,
secret: String,
}
impl Client {
pub fn new(uri: Uri, key: String, secret: String) -> Self {
assert!(uri.scheme().is_some(), "base uri must have a scheme");
assert!(uri.authority().is_some(), "base uri must have an authority");
Self {
http: hyper::Client::new(),
uri: uri,
key,
secret,
}
}
pub fn create_room(&self) {
// let mut uri = url.clone();
// uri.set_path_and_query()
let uri = Uri::builder()
.scheme(self.uri.scheme().unwrap().clone())
.authority(self.uri.authority().unwrap().clone())
.path_and_query("twirp/livekit.RoomService/CreateRoom")
.build();
// token::create(api_key, secret_key, room_name, participant_name)
// self.http.request(req)
2022-10-14 15:00:38 +00:00
}
}