From 12dd58c5668ed7060157f429c58ea707e02fe13f Mon Sep 17 00:00:00 2001 From: Tony Rewin Date: Fri, 6 Oct 2023 13:50:20 +0300 Subject: [PATCH] 80fix --- Cargo.toml | 4 ++-- Dockerfile | 10 +++++----- README.md | 1 + src/data.rs | 6 +++--- src/main.rs | 5 +++-- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bbe77aa..3415485 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,5 +15,5 @@ reqwest = { version = "0.11", features = ["json"] } futures = "0.3.28" [[bin]] -name = "presense" -path = "./src/main.rs" \ No newline at end of file +name = "presence" +path = "./src/main.rs" diff --git a/Dockerfile b/Dockerfile index 04b59d9..4acf7b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,8 @@ RUN apt-get update -y && \ apt-get install -y git pkg-config make g++ libssl-dev wget && \ rustup target add x86_64-unknown-linux-gnu -RUN USER=root cargo new --bin presense -WORKDIR /presense +RUN USER=root cargo new --bin presence +WORKDIR /presence COPY ./Cargo.lock ./Cargo.lock COPY ./Cargo.toml ./Cargo.toml @@ -20,7 +20,7 @@ RUN rm src/*.rs COPY ./src ./src # build for release -RUN rm ./target/release/deps/presense* +RUN rm ./target/release/deps/presence* RUN cargo build --release FROM rustlang/rust:nightly-slim @@ -28,5 +28,5 @@ FROM rustlang/rust:nightly-slim ENV RUST_BACKTRACE=full RUN apt-get update && apt install -y openssl libssl-dev -COPY --from=build /presense/target/release/presense . -CMD ["./presense"] +COPY --from=build /presence/target/release/presence . +CMD ["./presence"] diff --git a/README.md b/README.md index da4ff14..96d8c1e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ ### ENV - API_BASE + - AUTH_URL - REDIS_URL diff --git a/src/data.rs b/src/data.rs index de8a48f..3a35052 100644 --- a/src/data.rs +++ b/src/data.rs @@ -5,14 +5,14 @@ use std::error::Error; use std::env; pub async fn get_auth_id(token: &str) -> Result> { - 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() diff --git a/src/main.rs b/src/main.rs index a064f48..339d1b1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 -} \ No newline at end of file +} +