Skip to main content

joist/
lib.rs

1//! Joist is a backend framework for Rust with no third-party dependencies.
2//!
3//! ```no_run
4//! use joist::{Response, Router, Server};
5//!
6//! let mut router = Router::new();
7//! router.get("/hello/:name", |req| {
8//!     Response::text(format!("hello {}", req.param("name").unwrap_or("world")))
9//! });
10//!
11//! Server::new(router).bind("127.0.0.1:8080").unwrap().wait();
12//! ```
13//!
14//! # What is here, and what is not
15//!
16//! This is version 0.1. It ships routing, middleware, request and response
17//! types, a JSON value, configuration, a plugin trait, and a threaded HTTP/1.1
18//! server. WebSockets, authentication, migrations, background jobs, queues,
19//! caching and observability are on the roadmap and are **not** implemented.
20//! Nothing here pretends to do something it does not do.
21//!
22//! # Threads, not async
23//!
24//! Joist serves each connection on a worker thread from a fixed pool. That is a
25//! real ceiling: a few thousand idle connections cost a few thousand threads,
26//! where an async runtime would cost almost nothing. It buys a framework you can
27//! read in an afternoon, handlers that are ordinary functions, and stack traces
28//! that mean what they say. Choose accordingly.
29
30#![forbid(unsafe_code)]
31
32pub mod body;
33pub mod config;
34pub mod error;
35pub mod headers;
36pub mod json;
37pub mod method;
38pub mod middleware;
39pub mod plugin;
40pub mod pool;
41pub mod request;
42pub mod response;
43pub mod router;
44pub mod server;
45pub mod status;
46
47pub use body::Body;
48pub use config::Config;
49pub use error::{Error, Result};
50pub use headers::Headers;
51pub use json::Json;
52pub use method::Method;
53pub use middleware::{Cors, Middleware, RequestLog};
54pub use plugin::Plugin;
55pub use request::Request;
56pub use response::Response;
57pub use router::Router;
58pub use server::{Running, Server, Shutdown};
59pub use status::Status;
60
61/// The crate version, from Cargo at build time.
62pub const VERSION: &str = env!("CARGO_PKG_VERSION");