this post was submitted on 28 Dec 2023
36 points (97.4% liked)

Rust

5989 readers
34 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS
 

who?

Hello! I'm VΓ­ctor (aka Brian3647), a 15-year- old self-taught spanish developer. I love rust & cats, and I hate JS. I've been working on this project for ~2.5 months now:

what?

Snowboard (https://github.com/Brian3647/snowboard) is a library written in rust made for creating http/https servers easily. It supports json*, websockets*, TLS*, async*, http request parsing & response generation. *: enabled by feature

why?

Some developers like me prefer a simple API that can be freely extended for your app over a big system of complex proc macros where you have no idea what or how is happening. Snowboard offers a simplistic API that gives freedom of use to the developer without any complication or headache. You code your server just like you want it to be.

should I use snowboard?

Give it a try! From what I've seen, some people like a lot this way of coding servers, whereas other people can't live without #[get("/")]. Use it or not, giving a star to the project is always appreciated :)

example program (as of 1.0.3):

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

fn main() -> Result {
    let server = Server::new("localhost:8080")?;

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

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

        response!(ok, "Hello!", headers! { "X-Hello" => "World!" })
    })
}
top 2 comments
sorted by: hot top controversial new old
[–] Rognaut@lemmy.world 4 points 10 months ago (1 children)

Nice job! I'll have to try this out on my Pi 5.

[–] vicmdv@programming.dev 3 points 10 months ago

Ty! I haven't tested on raspberry pi, so make sure to tell me if anything isn't working as expected