Macro static_files

Source
macro_rules! static_files {
    ($($path:literal),*) => { ... };
}
Expand description

Macro to define static files by specifying their paths.

The files are included at compile time using the include_bytes! macro. The paths are relative to the static directory of the project (under the project root, where the Cargo.toml file is).

This is mainly useful with the CotApp::static_files trait method.

§Example

use bytes::Bytes;
use cot::{App, static_files};

pub struct ExampleApp;

// Project structure:
// .
// ├── Cargo.toml
// └── static
//     └── admin
//         └── admin.css

impl App for ExampleApp {
    fn name(&self) -> &str {
        "test_app"
    }

    fn static_files(&self) -> Vec<(String, Bytes)> {
        static_files!("admin/admin.css")
    }
}