Skip to main content

Crate zep

Crate zep 

Source
Expand description

§Zep is an async HTTP crate focusing on minimalism and simplicity.

I made it out of frustration with mainstream HTTP crates, I found that they were too bloated for simple use cases. I just wanted something simple, minimal, and reasonably fast.

§Example

Return a 200 OK response with content “Hello world!” at “GET / “.

use zep::{tokio, Router, Request, Response, Server, Method};

async fn root(_req: Request) -> Response {
    Response::ok("Hello world!")
}

#[tokio::main]
async fn main() {
    let mut router = Router::new();
    router.route(Method::GET, "/", root);

    let server = Server::new("0.0.0.0:8080", router);
    let _ = server.run().await;
}

Re-exports§

pub use tokio;

Modules§

serve
This is a helper module that contains useful utilities to serve and receive different kinds of content over HTTP.

Structs§

Request
Deserialized HTTP request in the form of a struct for easy handling in code. Contains request method, path, version, headers, body, remote_addr(ip address of client), and parameters.
Response
Deserialized HTTP response in the form of a struct for easy handling in code. Contains status_code(status code), headers and body.
Router
Router struct, contains routes and the methods needed to route requests to them.
Server
Server that wraps the whole HTTP server in itself.
StreamReader
used for streamed file reading
StreamWriter
Used for responding with streams.

Enums§

Method
Enum for quick and memory efficient method handling.
StatusCode
Enum to conveniently handle status codes.
Version
Enum for quick and memory efficient HTTP version handling.

Type Aliases§

Handler
Type alias of async handler function for usage in middleware. A Handler has the following signature: async fn handler(Request) -> Response
HeaderMap
Type alias of HashMap<String, String> for convenience.
ParamMap
Type alias of HashMap<String, String> for convenience.