2020-11-14 08:55:21 +00:00
|
|
|
use anyhow::*;
|
|
|
|
use log::LevelFilter;
|
2020-11-25 05:42:09 +00:00
|
|
|
use kochab::{Server, Response, GEMINI_PORT, Document};
|
|
|
|
use kochab::document::HeadingLevel::*;
|
2020-11-14 08:55:21 +00:00
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<()> {
|
|
|
|
env_logger::builder()
|
2020-11-25 05:42:09 +00:00
|
|
|
.filter_module("kochab", LevelFilter::Debug)
|
2020-11-14 08:55:21 +00:00
|
|
|
.init();
|
|
|
|
|
2020-11-24 04:30:59 +00:00
|
|
|
let response: Response = Document::new()
|
2020-11-25 05:42:09 +00:00
|
|
|
.add_preformatted_with_alt("kochab", include_str!("kochab_logo.txt"))
|
2020-11-20 04:39:07 +00:00
|
|
|
.add_blank_line()
|
2020-11-25 05:42:09 +00:00
|
|
|
.add_text(
|
|
|
|
concat!(
|
|
|
|
"Kochab is an extension & a fork of the Gemini SDK [northstar]. Where",
|
|
|
|
" northstar creates an efficient and flexible foundation for Gemini projects,",
|
|
|
|
" kochab seeks to be as ergonomic and intuitive as possible, making it",
|
|
|
|
" possible to get straight into getting your ideas into geminispace, with no",
|
|
|
|
" worrying about needing to build the tools to get there."
|
|
|
|
)
|
|
|
|
)
|
2020-11-20 04:39:07 +00:00
|
|
|
.add_blank_line()
|
2020-11-25 05:42:09 +00:00
|
|
|
.add_link("https://github.com/Alch-Emi/kochab", "GitHub")
|
2020-11-20 04:39:07 +00:00
|
|
|
.add_blank_line()
|
2020-11-25 05:42:09 +00:00
|
|
|
.add_heading(H2, "Usage")
|
2020-11-20 04:39:07 +00:00
|
|
|
.add_blank_line()
|
2020-11-25 05:42:09 +00:00
|
|
|
.add_text("Add the latest version of kochab to your `Cargo.toml`.")
|
2020-11-20 04:39:07 +00:00
|
|
|
.add_blank_line()
|
2020-11-25 05:42:09 +00:00
|
|
|
.add_preformatted_with_alt("toml", r#"kochab = { git = "https://github.com/Alch-Emi/kochab.git" }"#)
|
2020-11-20 04:39:07 +00:00
|
|
|
.add_blank_line()
|
2020-11-25 05:42:09 +00:00
|
|
|
.add_heading(H2, "Generating a key & certificate")
|
2020-11-20 04:39:07 +00:00
|
|
|
.add_blank_line()
|
|
|
|
.add_preformatted_with_alt("sh", concat!(
|
|
|
|
"mkdir cert && cd cert\n",
|
|
|
|
"openssl req -x509 -nodes -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365",
|
2020-11-23 15:55:48 +00:00
|
|
|
))
|
|
|
|
.into();
|
2020-11-24 04:30:59 +00:00
|
|
|
|
|
|
|
Server::bind(("localhost", GEMINI_PORT))
|
|
|
|
.add_route("/", response)
|
|
|
|
.serve()
|
|
|
|
.await
|
2020-11-14 08:55:21 +00:00
|
|
|
}
|