An ergonomic and elegant framework for creating Gemini servers and SCGI apps without needless bloat
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.1 KiB

use std::path::PathBuf;
use anyhow::*;
use log::LevelFilter;
use kochab::Server;
/// Serving some static content from the filesystem is easy with Kochab
/// This example serves from the `./public` directory on the base route, and adds a
/// special one-page bind to `/about` that always serves ``
/// Note, use this module with a little bit of caution. The directory serving feature is
/// currently unfinished, and the API is subject to change dramatically in future updates.
/// It should be secure, but you may need to do some refactoring in coming updates.
async fn main() -> Result<()> {
// We set up logging so we can see what's happening. This isn't technically required,
// and you can use a simpler solution (like env_logger::init()) during production
.filter_module("kochab", LevelFilter::Debug)
.add_route("/", PathBuf::from("public")) // Serve directory listings & file contents
.add_route("/about", PathBuf::from("")) // Serve a single file