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.

34 lines
1.1 KiB

use std::time::Duration;
use anyhow::*;
use log::LevelFilter;
use kochab::{Server, Request, Response, Document};
async fn main() -> Result<()> {
.filter_module("kochab", LevelFilter::Debug)
.add_route("/", handle_request)
.ratelimit("/limit", 2, Duration::from_secs(60))
async fn handle_request(request: Request) -> Result<Response> {
let mut document = Document::new();
if let Some("limit") = request.trailing_segments().get(0).map(String::as_str) {
document.add_text("You're on a rate limited page!")
.add_text("You can only access this page twice per minute");
} else {
document.add_text("You're on a normal page!")
.add_text("You can access this page as much as you like.");
.add_link("/limit", "Go to rate limited page")
.add_link("/", "Go to a page that's not rate limited");