ryde_static_files

Crates.ioryde_static_files
lib.rsryde_static_files
version0.1.0
sourcesrc
created_at2024-02-29 17:34:41.561535
updated_at2024-02-29 17:34:41.561535
descriptionstatic files crate for ryde
homepagehttps://github.com/swlkr/ryde
repositoryhttps://github.com/swlkr/ryde
max_upload_size
id1158018
size2,070
swlkr (swlkr)

documentation

README

Static files

Static files provides an easy way to declare and embed your static files.

Declare your static files

This will embed the static files in your binary at compile time with include_bytes!. It will try to find the files starting from the root of your project: CARGO_MANIFEST_DIR.

use ryde::*;

#[main]
async fn main() {
    serve!("localhost:3000", Routes)
}

#[router]
enum Routes {
    #[embed("/static/*file")]
    StaticFiles
}

Render them

fn render() -> String {
    ryde::render((
        doctype(),
        html((
            head(render!(StaticFiles)),
            body(),
        )),
    ))
}
Commit count: 115

cargo fmt