diff --git a/Dockerfile b/Dockerfile index 026335c..d2d82f4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM rust:latest AS builder-demo WORKDIR /build/demo RUN apt update && apt install -y g++-mingw-w64-x86-64 - +ARG RAILWAY_PUBLIC_DOMAIN RUN rustup target add x86_64-pc-windows-gnu RUN rustup target add x86_64-unknown-linux-gnu diff --git a/demo/src/main.rs b/demo/src/main.rs index c1f0781..cb41b7d 100644 --- a/demo/src/main.rs +++ b/demo/src/main.rs @@ -10,10 +10,17 @@ struct KeyData<'a> { } static KEY: &'static str = include_str!(concat!(env!("OUT_DIR"), "/key.json")); +const HOST_INFO: (&'static str, &'static str) = match option_env!("RAILWAY_PUBLIC_DOMAIN") { + Some(domain) => ("https", domain), + None => ("http", "localhost"), +}; fn main() { let key_data: KeyData = serde_json::from_str(KEY).unwrap(); + let (protocol, domain) = HOST_INFO; + println!("Protocol: {}, Domain: {}", protocol, domain); + // Print the key data let args: Vec = std::env::args().collect(); if args.contains(&"--help".to_string()) { @@ -38,8 +45,8 @@ fn main() { let client = reqwest::blocking::Client::new(); let response = client .post(&format!( - "http://localhost:5800/notify?key={}", - key_data.value + "{}://{}/notify?key={}", + HOST_INFO.0, HOST_INFO.1, key_data.value )) .send();