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"
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!" })
})
}
More info (& how to use async, tls, and other features) can be found in the readme. Happy coding!
repo:
Snowboard π
An extremely simple (& blazingly fast) library for HTTP & HTTPS servers in Rust
Table of Contents
Quick start
To get started with Snowboard, simply add it to your Cargo.toml
file:
[dependencies]
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
β¦
Top comments (0)