highnoon

Crates.iohighnoon
lib.rshighnoon
version0.0.9
sourcesrc
created_at2021-02-07 00:42:25.96116
updated_at2022-11-01 05:20:09.299358
descriptionminimal web server framework inspired by tide, but built on hyper
homepage
repositoryhttps://github.com/sphenlee/highnoon
max_upload_size
id351736
size100,427
(sphenlee)

documentation

https://docs.rs/highnoon

README

Highnoon

crates.io API docs MIT licensed

A minimal web framework built on Hyper

This is a very early development release. While I'm pretty happy with the API so far, anything could change.

To get started first implement the State trait which holds all data shared by all the route handlers. This trait contains a single method to get a new Context which is the data shared for the duration of a single request. Context is generally used for sharing data between filters.

struct MyState;

impl highnoon::State for MyState {
    type Context = ();

    fn new_context(&self) -> Context {
        ()
    }
}

Then create an App with your State, attach filters and routes and launch the server.

#[tokio::main]
async fn main() -> highnoon::Result<()> {
    let mut app = highnoon::App::new(MyState);

    app.with(highnoon::filter::Log);

    app.at("/hello").get(|_request| async {
        "Hello world!\n\n"
    });

    app.listen("0.0.0.0:8888").await?;
    Ok(())
}
Commit count: 57

cargo fmt