DEV Community

Cover image for Snowboard v1.0.0 is here! πŸ‚πŸ¦€
Brian3647
Brian3647

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

Extremely simple http rust servers πŸ‚

Snowboard πŸ‚

License GitHub issues 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
  1. Snowboard πŸ‚
    1. Quick start
    2. Async routes
    3. TLS
    4. Websockets
    5. Routing
    6. Integration
    7. MSRV (Minimum Supported Rust Version)
    8. Contributing
    9. License

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!(method_not_allowed, "Caught you
…
Enter fullscreen mode Exit fullscreen mode

Top comments (0)