Crates.io | viz-smol |
lib.rs | viz-smol |
version | 0.1.9 |
source | src |
created_at | 2024-01-12 22:54:09.477318 |
updated_at | 2024-06-23 10:13:29.316718 |
description | An adapter for smol runtime |
homepage | https://viz.rs |
repository | https://github.com/viz-rs/viz |
max_upload_size | |
id | 1098105 |
size | 16,958 |
Fast, robust, flexible, lightweight web framework for Rust
Safety #![forbid(unsafe_code)]
Lightweight
Robust Routing
Handy Extractors
Simple + Flexible Handler
& Middleware
Supports Tower Service
use std::io;
use std::sync::Arc;
use async_net::TcpListener;
use macro_rules_attribute::apply;
use viz_smol::{IntoResponse, Request, Response, Result, Router};
async fn index(_: Request) -> Result<Response> {
Ok("<h1>Hello, World!</h1>".into_response())
}
#[apply(smol_macros::main!)]
async fn main(ex: &Arc<smol_macros::Executor<'_>>) -> io::Result<()> {
// Build our application with a route.
let app = Router::new().get("/", index);
// Create a `smol`-based TCP listener.
let listener = TcpListener::bind(("127.0.0.1", 3000)).await.unwrap();
println!("listening on {}", listener.local_addr().unwrap());
// Run it
viz_smol::serve(ex.clone(), listener, app).await
}
More examples can be found here.
Open Viz.rs, select language or version.
This project is licensed under the MIT license.