Cataclysm. A simple rust http server
Work in progress: The work is completely unusable in its current state, but updates will come soon until a full HTTP/1.1 server is functional. This legend will be removed when such a state is reached.
Cataclysm is an http framework influenced by actix-web, and built over tokio. A minimal working example is the following
extern crate cataclysm;
use ;
async
async
Closures as callbacks
Until async closures become stable, the option to pass closures as a path handler is with a closure that returns an async block
let server = builder.build;
Extractors
Some data can be retrieved from an http request by just adding arguments to the callback, with types that implement the Extractor trait. The default implementation list is the following
String: Tries to extract the body as a valid utf-8 string. Returns Bad-Request if the operation failsVec<u8>: Returns the content of thehttpcall as a stream of bytesRequest: Returns the request for a bit more control within the callback
Layers
Cataclysm allows for layer handling, a.k.a. middleware.
let path = new
.with
.layer.nested;
As seen in the example, layer functions receive a Request and a boxed Pipeline enum. The Pipeline enum contains a nested structure of futures (the layers + the core handler), and has the execute to simplify things a bit. This function must return a Pin<Box<_>> future, so either use the boxed method from the FutureExt trait from the futures crate, or wrap it manually.