macro_rules! file {
($file_name:expr, $e:expr) => { ... };
($file_name:expr, $e:expr, [ $( ($key:expr, $value:expr) ),* $(,)? ]) => { ... };
}Expand description
Produces OK 200 response with file body
This macro is working only within async context, make sure that you are using
AsyncEndpointsMapping
§Examples
§Default usage
use volga::file;
use tokio::fs::File;
let file_name = "example.txt";
let file_data = File::open(file_name).await?;
file!(file_name, file_data);§Custom headers
use volga::{file, App, Router};
use tokio::fs::File;
let file_name = "example.txt";
let file_data = File::open(file_name).await?;
file!(file_name, file_data, [
("x-api-key", "some api key")
]);