Expand description
Fast, robust, flexible, lightweight web framework for Rust.
🦀 Features
-
Safety
#![forbid(unsafe_code)]
-
Lightweight
-
Robust
Routing
-
Flexible + Simple
Handler
&Middleware
-
Easy use
Extractors
Example
use std::net::SocketAddr;
use viz::{get, Body, Request, Result, Router, Server, ServiceMaker};
async fn index(_: Request<Body>) -> Result<&'static str> {
Ok("Hello, World!")
}
#[tokio::main]
async fn main() -> Result<()> {
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("listening on {}", addr);
let app = Router::new().route("/", get(index));
if let Err(err) = Server::bind(&addr)
.tcp_nodelay(true)
.serve(ServiceMaker::from(app))
.await
{
println!("{}", err);
}
Ok(())
}
Re-exports
pub use viz_handlers as handlers;
Modules
Structs
A stream of Bytes
, used when receiving bodies.
A cheaply cloneable and sliceable chunk of contiguous memory.
A unique reference to a contiguous slice of memory.
The Request Method (VERB)
A path tree.
Responder with extractor
A listening HTTP server that accepts connections in both HTTP1 and HTTP2 by default.
An HTTP status code (status-code
in RFC 7230 et al.).
Enums
Traits
A handler with extractors
Composable request handlers.
An extension trait for Handler
s that provides a variety of convenient
combinator functions.
Functions
stream
Adapt a Stream
of incoming connections into an Accept
.
Appends a route, with handler by any HTTP verbs.
Appends a route, handle HTTP verb CONNECT
.
Appends a route, handle HTTP verb DELETE
.
Appends a route, handle HTTP verb GET
.
Appends a route, handle HTTP verb HEAD
.
Appends a route, with a HTTP verb and handler.
Appends a route, handle HTTP verb OPTIONS
.
Appends a route, handle HTTP verb PATCH
.
Appends a route, handle HTTP verb POST
.
Appends a route, handle HTTP verb PUT
.
Appends a route, handle HTTP verb TRACE
.
Type Definitions
Attribute Macros
macros