Skip to main content

Crate churust_core

Crate churust_core 

Source
Expand description

Churust core kernel: the engine, routing, request pipeline, and extractors that power the Churust web framework.

Churust is a Ktor-inspired, async-first web framework for Rust. This crate (churust-core) is the foundation every other Churust crate builds on. It provides:

§Example

Build an app, register a route, and exercise it with the in-process test client (no socket is bound, so this runs in any environment):

use churust_core::{Churust, Call, TestClient};
let app = Churust::server()
    .routing(|r| {
        r.get("/", |_c: Call| async { "Hello, Churust!" });
    })
    .build();

let res = TestClient::new(app).get("/").send().await;
assert_eq!(res.status().as_u16(), 200);
assert_eq!(res.text(), "Hello, Churust!");

To actually serve traffic, call App::start (binds a socket and serves until Ctrl-C) or AppBuilder::start.

Re-exports§

pub use body::Body;
pub use error::Error;
pub use error::Result;
pub use response::IntoResponse;
pub use response::Response;
pub use call::Call;
pub use handler::boxed;
pub use handler::BoxHandler;
pub use handler::Handler;
pub use handler::IntoHandler;
pub use state::StateMap;
pub use extract::BearerToken;
pub use extract::FromCall;
pub use extract::FromCallParts;
pub use extract::Path;
pub use extract::Query;
pub use extract::State;
pub use router::Match;
pub use router::RouteBuilder;
pub use router::Router;
pub use pipeline::Endpoint;
pub use pipeline::Middleware;
pub use pipeline::Next;
pub use pipeline::Phase;
pub use config::Config;
pub use config::ServerSection;
pub use config::TlsSection;
pub use app::App;
pub use app::AppBuilder;
pub use app::Churust;
pub use app::Plugin;
pub use app::ServerConfig;
pub use ws::WebSocket;
pub use ws::WebSocketUpgrade;
pub use fs::StaticFiles;
pub use test::TestClient;
pub use test::TestRequest;
pub use test::TestResponse;

Modules§

app
Application assembly: the Churust entry point, the AppBuilder DSL, the immutable App, the Plugin trait, and the resolved ServerConfig.
body
The response Body: either a fully-buffered Bytes payload or a lazy stream of byte chunks (for files, large/dynamic responses, SSE, etc.).
call
The per-request Call context — the single object every handler receives.
config
Layered configuration: defaults < churust.toml < env (CHURUST_*) < code.
engine
The hyper-based HTTP/1.1 serving engine that drives an App over a real socket.
error
The status-carrying Error type and the crate-wide Result alias.
extract
Extractors: typed handler arguments derived from a Call.
fs
Static file serving (feature fs).
handler
Handlers: the Handler trait, handler closures, and the glue that turns extractor closures into stored handlers.
pipeline
The request pipeline: Middleware, the Phase ordering, the Next continuation, and the Endpoint terminal.
response
The buffered Response type and the IntoResponse conversion trait.
router
The trie-based Router, its Match result, and the RouteBuilder DSL used inside AppBuilder::routing.
state
Type-keyed shared application state (a minimal DI registry).
test
In-process test harness. Drives App::process directly — no socket bind.
tls
TLS support (feature tls). Loads a PEM cert chain + private key and builds a tokio_rustls::TlsAcceptor with rustls’ safe defaults.
ws
WebSocket support (feature ws).