feat: boxygit add .

This commit is contained in:
hexlocation 2025-07-29 11:47:02 +02:00
parent ba8d1b9453
commit a8bc61f40c
15 changed files with 4700 additions and 0 deletions

View file

@ -0,0 +1,41 @@
use std::{collections::HashMap, fmt::format};
use rocket::{build, get, launch, routes};
use serde_json::json;
extern crate rocket;
const BOXY_ADDRESS: &str = "localhost";
const BOXY_PORT: u16 = 8006;
const CLIENT_NAME: &str = "eu-central-1";
const CLIENT_SECRET: &str = "password123";
#[get("/")]
fn index() -> &'static str {
"Hello world!"
}
#[launch]
fn rocket() -> _ {
// This is the example backend client. (The stereo.cat backend for example).
let client = reqwest::blocking::Client::new();
// We define the port of the server running locally and the hostname we want to route to it.
let body = json!({
"port": 8000,
"hostname": "localhost:8005",
});
// Send it to Boxy's API
let res = client
.post(format!("http://{}:{}/register", BOXY_ADDRESS, BOXY_PORT))
.basic_auth(CLIENT_NAME, Some(CLIENT_SECRET))
.json(&body)
.send()
.unwrap();
println!("{}", res.text().unwrap());
build().mount("/", routes![index])
}