A forward-thinking fast web server designed to fit your needs, efficiently.
Kvarn is a rusty, open-source, extendable web application framework with native async everywhere; zero downtime; and safe & fast defaults.
Kvarn is batteries-included (optional defaults) with support for automatic HTTPS certificates, HTTP/3, io_uring everywhere, reverse proxying, auto HTTP/2 push, in-memory caching (proper cache invalidation), server communication provided by a simple CLI, and easy website creation through Markdown and Chute.
You can follow progress on GitHub where the project is hosted. The project is under active development to add features, reduce complexity, improve performance, and fix issues.
See Mölla for how to install the reference Kvarn implementation. You'll have a web server running in under 5 minutes and the power to write search-indexed websites with user authentication in no time.
We recommend using Kvarn Chute for writing documents. It allows you to use Markdown on web pages. Providing automatic table of contents, date widgets, and other features, it's a convenient way to write text documents without limiting HTML use.
Kvarn is programmed using Rust. You'll need to download it before using the Kvarn web server.
Then, enter a directory and initiate a Cargo (Rust's package manager, like NPM to node.js) project.
$ cargo init
Next, add these dependencies in your Cargo.toml
.
kvarn = "0.5"
tokio = { version = "1.20", features = ["rt-multi-thread", "macros"] }
env_logger = "0.9"
Now, you can edit src/main.rs
and replace the
Hello world!
example with this.
use kvarn::prelude::*;
#[tokio::main]
async fn main() {
// Initiate the logger. Set the environment variable `RUST_LOG` to `info` to get more verbose logging.
env_logger::init();
// Create a host without HTTPS with hostname "localhost", serving files from directory "./web/public/", with the default extensions and the default options.
let host = Host::unsecure("localhost", PathBuf::from("web"), Extensions::default(), host::Options::default());
// Create a collection of virtual hosts with `host`.
let hosts = HostCollection::builder().insert(host).build();
// Serve `hosts` on port 8080 without HTTPS
let port_descriptor = PortDescriptor::unsecure(8080, hosts);
// Run the server. You can specify multiple PortDescriptors.
let shutdown_manager = RunConfig::new().bind(port_descriptor).execute().await;
// Wait for shutdown. This will never happen with this setup,
// but you can clone `shutdown_manager` and shut the server down from other threads.
shutdown_manager.wait().await;
}
Start it with the following command.