This commit is contained in:
2023-10-06 13:50:20 +03:00
parent c24fee0011
commit 12dd58c566
5 changed files with 14 additions and 12 deletions

View File

@@ -5,14 +5,14 @@ use std::error::Error;
use std::env;
pub async fn get_auth_id(token: &str) -> Result<i32, Box<dyn Error>> {
let api_base = env::var("API_BASE")?;
let gql = match api_base.contains("v2") {
let auth_api_base = env::var("AUTH_URL")?;
let gql = match auth_api_base.contains("v2") {
true => r#"mutation { getSession { user { id } } }"#, // v2
_ => r#"query { sessiom { user { id } } }"# // authorizer
};
let client = HTTPClient::new();
let response = client
.post(api_base)
.post(auth_api_base)
.bearer_auth(token) // NOTE: auth token is here
.body(gql)
.send()

View File

@@ -77,7 +77,8 @@ async fn main() -> std::io::Result<()> {
.route("/connect", web::get().to(sse_handler))
.route("/disconnect", web::get().to(sse_handler))
})
.bind("127.0.0.1:8080")?
.bind("127.0.0.1:80")?
.run()
.await
}
}