use anyhow::*; use futures_core::future::BoxFuture; use futures_util::FutureExt; use log::LevelFilter; use northstar::{Server, Request, Response, GEMINI_PORT, Gemtext}; #[tokio::main] async fn main() -> Result<()> { env_logger::builder() .filter_module("northstar", LevelFilter::Debug) .init(); Server::bind(("localhost", GEMINI_PORT)) .serve(handle_request) .await } fn handle_request(_request: Request) -> BoxFuture<'static, Result> { async move { let response = Gemtext::new() .preformatted("Northstar", include_str!("northstar_logo.txt")) .blank_line() .link("https://docs.rs/northstar", Some("Documentation")) .link("https://github.com/panicbit/northstar", Some("GitHub")) .blank_line() .heading(1, "Usage") .blank_line() .text("Add the latest version of northstar to your `Cargo.toml`.") .blank_line() .heading(2, "Manually") .blank_line() .preformatted("toml", r#"northstar = "0.3.0" # check crates.io for the latest version"#) .blank_line() .heading(2, "Automatically") .blank_line() .preformatted("sh", "cargo add northstar") .blank_line() .heading(1, "Generating a key & certificate") .blank_line() .preformatted("sh", concat!( "mkdir cert && cd cert\n", "openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365", )) .into(); Ok(response) } .boxed() }