* Fixing url construction for websockets
This commit is contained in:
parent
5df5329b6c
commit
bdd4a63a8d
@ -4,8 +4,6 @@ use reqwest::{Client, Url, Body, Response};
|
|||||||
use reqwest::header::{HeaderMap, HeaderValue, CONTENT_TYPE};
|
use reqwest::header::{HeaderMap, HeaderValue, CONTENT_TYPE};
|
||||||
use reqwest::Result as HttpResult;
|
use reqwest::Result as HttpResult;
|
||||||
|
|
||||||
// TODO: Url generation is kinda gross looking but i'm not 100%
|
|
||||||
// convinced it needs to be pretty if its just going to add overhead
|
|
||||||
|
|
||||||
pub async fn login(url: &str, id: u64, secret: &str) -> HttpResult<String> {
|
pub async fn login(url: &str, id: u64, secret: &str) -> HttpResult<String> {
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
@ -55,5 +53,11 @@ pub async fn send_text<'m>(url: &str, id: u64, jwt: &str, chan: u64, msg: &str)
|
|||||||
Ok(client.post(url).body(body).headers(headers).send().await?)
|
Ok(client.post(url).body(body).headers(headers).send().await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn setup_websocket(url: &str) {
|
pub fn ws_url(base: &str, jwt: Option<String>) -> String {
|
||||||
|
let base = format!("{}/text", base);
|
||||||
|
let jwt = jwt.unwrap_or("hehexd".into());
|
||||||
|
let mut url = Url::parse_with_params(base.as_ref(), &[("jwt", jwt.as_str())]).unwrap();
|
||||||
|
let _ = url.set_port(Some(5648));
|
||||||
|
let _ = url.set_scheme("ws");
|
||||||
|
url.to_string()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user