#http #server #web


Extremely simple rust servers πŸ‚

30 releases (2 stable)

new 1.0.1 Dec 2, 2023
1.0.0 Nov 22, 2023
0.7.3 Nov 20, 2023

#61 in HTTP server

Download history 241/week @ 2023-10-20 130/week @ 2023-10-27 125/week @ 2023-11-03 209/week @ 2023-11-10 132/week @ 2023-11-17 68/week @ 2023-11-24 109/week @ 2023-12-01

536 downloads per month

MIT license

826 lines

Snowboard πŸ‚

License GitHub issues Build status DeepSource dependency status

An asynchronous, extremely simple (& blazingly fast) library for HTTP & HTTPS servers in Rust

Request a feature/Report a bug

Table of Contents

Quick start

To get started with Snowboard, simply add it to your Cargo.toml file:

snowboard = "*"

Then, create a new Rust file with the following code:

use snowboard::{headers, response, Method, Result, Server};

fn main() -> Result {
    let data = "Hello, world!";

    let server = Server::new("localhost:8080")?;

    println!("Listening on {}", server.pretty_addr()?);

    server.run(move |mut req| {
        if req.method == Method::DELETE {
            return response!(method_not_allowed, "Caught you trying to delete!");

        req.set_header("X-Server", "Snowboard");


        response!(ok, data, headers! { "X-Hello" => "World!" })

And that's it! You got yourself a working server on :8080. Examples can be found in the examples folder.

Async routes

You can use the async feature and Server::run_async to run async routes:

# Cargo.toml

snowboard = { version = "*", features = ["async"] }
// src/main.rs
use snowboard::{Request, ResponseLike, Server, Result};
use async_std::task;
use std::duration::Duration;

async fn index(_: Request) -> impl ResponseLike {

    "Async works"

fn main() -> Result {


Use the tls feature (which will also install native-tls) to use TLS:

use anyhow::Result;
use snowboard::{
    Identity, TlsAcceptor,
    response, Server,

use std::fs;

fn main() -> Result<()> {
    let der = fs::read("identity.pfx")?;
    let password = ..;
    let tls_acceptor = TlsAcceptor::new(Identity::from_pkcs12(&der, password)?)?;

    Server::new_with_tls("localhost:3000", tls_acceptor)?
        .run(|request| format!("{request:#?}"))

You can confirm it works by running curl -k https://localhost:3000 (the -k is needed to allow self-signed certificates)

More info can be found in examples/tls.


WebSockets are easy to implement with the websocket feature. Example (echo server):

use std::net::TcpStream;

use snowboard::Server;
use snowboard::WebSocket;

fn handle_ws(mut ws: WebSocket) {
    while let Ok(msg) = ws.read() {

fn main() -> snowboard::Result {
        .on_websocket("/ws", handle_ws)
        .run(|_| "Try `/ws`!")


Routing can be handled easily using the Url struct:

use snowboard::{response, Request, ResponseLike, Result, Server};

fn router(req: Request) -> impl ResponseLike {
    // /{x}
    match req.parse_url().at(0) {
        Some("ping") => response!(ok, "Pong!"),
        Some("api") => response!(not_implemented, "πŸ‘€"),
        None => response!(ok, "Hello, world!"),
        _ => response!(not_found, "Route not found"),

fn main() -> Result {



JSON is supported with the json feature (serializing & deserializing):

use serde_json::Value;
use snowboard::{Response, Server};

struct Example {
    number: isize,

fn main() -> snowboard::Result {
    Server::new("localhost:8080")?.run(|req| -> Result<Value, Response> {
        let example: Example = req.force_json()?;

            "number_plus_one": example.number + 1
use snowboard::Server;

fn main() -> snowboard::Result {
    Server::new("localhost:3000")?.run(|r| {
            "ip": r.ip(),
            "url": r.parse_url(),
            "method": r.method,
            "body": r.text(),
            "headers": r.headers,

force_json returns a result of either the parsed JSON or a bad request response. If you want to handle the error yourself, use json instead.


Snowboard's ResponseLike is designed to work with pretty much anything, but it wont by default with certain cases like maud's html! macro. If you happen to use a lot a crate that doesn't work with Snowboard, please open an issue, pr or implement ResponseLike for it:

use snowboard::{Response, ResponseLike, Server};

struct Example {
    num: usize,

impl ResponseLike for Example {
    fn to_response(self) -> Response {
        snowboard::response!(ok, self.num.to_string())

fn main() -> snowboard::Result {
        .run(|_| Example { num: 5 });

MSRV (Minimum Supported Rust Version)

The MSRV is 1.60.0, but it might change (lower or higher) depending on which features are enabled.


Check CONTRIBUTING.md for a simple guide on how to help the project.


This code is under the MIT license that can be found at LICENSE


~134K SLoC