// 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)] struct Config { name: String, description: String, url: String, port: u16 } pub async fn server_meta(response: &mut Response) { let payload = Config { name: var("SERVER_NAME").unwrap_or("No name".into()), description: var("SERVER_DESCRIPTION").unwrap_or("No description".into()), url: var("SERVER_URL").expect("Couldn't get url from environment"), port: var("SERVER_PORT").expect("Couldn't get port from environment").parse::().unwrap(), }; *response.body_mut() = Body::from(to_string(&payload).unwrap()); }