DEV Community

Cover image for Snowboard v1.0.0 is here! 🏂🦀
vicmdv
vicmdv

Posted on

Snowboard v1.0.0 is here! 🏂🦀

I first talked online about snowboard here, and now, only 27 days after, snowboard 1.0.0 is available & production-ready!

What is snowboard?

Snowboard is a tool for creating extremely fast web servers in rust. It comes with its own request & url parser and a bunch of optional features like JSON/serde support, TLS security, WebSockets & asynchronous handlers.

Quickstart

You can install snowboard by adding it to your Cargo.toml:

[dependencies]
snowboard = "1"
Enter fullscreen mode Exit fullscreen mode

and use it without any need of macro derives:

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

fn main() -> snowboard::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");

        println!("{req:#?}");

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

More info (& how to use async, tls, and other features) can be found in the readme. Happy coding!

repo:

GitHub logo Brian3647 / snowboard

fast, simple & reliable http rust servers 🏂

Snowboard 🏂

License Build status DeepSource dependency status

An 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:

[dependencies]
snowboard = "*"
Enter fullscreen mode Exit fullscreen mode

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!
Enter fullscreen mode Exit fullscreen mode

Top comments (0)