mirror of
https://github.com/Xevion/dynamic-preauth.git
synced 2025-12-06 01:14:55 -06:00
include const time host info for reqwest endpoint
This commit is contained in:
@@ -3,7 +3,7 @@ FROM rust:latest AS builder-demo
|
|||||||
|
|
||||||
WORKDIR /build/demo
|
WORKDIR /build/demo
|
||||||
RUN apt update && apt install -y g++-mingw-w64-x86-64
|
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-pc-windows-gnu
|
||||||
RUN rustup target add x86_64-unknown-linux-gnu
|
RUN rustup target add x86_64-unknown-linux-gnu
|
||||||
|
|||||||
@@ -10,10 +10,17 @@ struct KeyData<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static KEY: &'static str = include_str!(concat!(env!("OUT_DIR"), "/key.json"));
|
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() {
|
fn main() {
|
||||||
let key_data: KeyData = serde_json::from_str(KEY).unwrap();
|
let key_data: KeyData = serde_json::from_str(KEY).unwrap();
|
||||||
|
|
||||||
|
let (protocol, domain) = HOST_INFO;
|
||||||
|
println!("Protocol: {}, Domain: {}", protocol, domain);
|
||||||
|
|
||||||
// Print the key data
|
// Print the key data
|
||||||
let args: Vec<String> = std::env::args().collect();
|
let args: Vec<String> = std::env::args().collect();
|
||||||
if args.contains(&"--help".to_string()) {
|
if args.contains(&"--help".to_string()) {
|
||||||
@@ -38,8 +45,8 @@ fn main() {
|
|||||||
let client = reqwest::blocking::Client::new();
|
let client = reqwest::blocking::Client::new();
|
||||||
let response = client
|
let response = client
|
||||||
.post(&format!(
|
.post(&format!(
|
||||||
"http://localhost:5800/notify?key={}",
|
"{}://{}/notify?key={}",
|
||||||
key_data.value
|
HOST_INFO.0, HOST_INFO.1, key_data.value
|
||||||
))
|
))
|
||||||
.send();
|
.send();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user