// Basic handler for getting meta data about the server use std::env::var; use hyper::{Response, Body}; use serde_json::to_string; use serde::Serialize; #[derive( Serialize)] pub struct Config { pub name: String, pub description: String, pub hostname: String, pub port: u16 } pub fn get_config() -> Config { Config { name: var("SERVER_NAME").unwrap_or("No name".into()), description: var("SERVER_DESCRIPTION").unwrap_or("No description".into()), hostname: var("SERVER_HOSTNAME").expect("Couldn't get url from environment"), port: var("SERVER_PORT").expect("Couldn't get port from environment").parse::().unwrap(), } } pub async fn server_meta(response: &mut Response) { *response.body_mut() = Body::from(to_string(&get_config()).unwrap()); }