Skip to main content

Crate joist

Crate joist 

Source
Expand description

Joist is a backend framework for Rust with no third-party dependencies.

use joist::{Response, Router, Server};

let mut router = Router::new();
router.get("/hello/:name", |req| {
    Response::text(format!("hello {}", req.param("name").unwrap_or("world")))
});

Server::new(router).bind("127.0.0.1:8080").unwrap().wait();

§What is here, and what is not

This is version 0.1. It ships routing, middleware, request and response types, a JSON value, configuration, a plugin trait, and a threaded HTTP/1.1 server. WebSockets, authentication, migrations, background jobs, queues, caching and observability are on the roadmap and are not implemented. Nothing here pretends to do something it does not do.

§Threads, not async

Joist serves each connection on a worker thread from a fixed pool. That is a real ceiling: a few thousand idle connections cost a few thousand threads, where an async runtime would cost almost nothing. It buys a framework you can read in an afternoon, handlers that are ordinary functions, and stack traces that mean what they say. Choose accordingly.

Re-exports§

pub use body::Body;
pub use config::Config;
pub use error::Error;
pub use error::Result;
pub use headers::Headers;
pub use json::Json;
pub use method::Method;
pub use middleware::Cors;
pub use middleware::Middleware;
pub use middleware::RequestLog;
pub use plugin::Plugin;
pub use request::Request;
pub use response::Response;
pub use router::Router;
pub use server::Running;
pub use server::Server;
pub use server::Shutdown;
pub use status::Status;

Modules§

body
config
error
headers
json
method
middleware
plugin
pool
request
response
router
server
status

Constants§

VERSION
The crate version, from Cargo at build time.