Crates.io | rocket_anyhow |
lib.rs | rocket_anyhow |
version | 0.1.1 |
source | src |
created_at | 2021-04-23 08:44:46.467283 |
updated_at | 2021-04-23 08:49:43.31458 |
description | throw any error inside rocket's route |
homepage | |
repository | |
max_upload_size | |
id | 388513 |
size | 5,044 |
This library provided rocket_anyhow::Error
,
a wrapper around anyhow::Error
with rocket's responder implemented.
use std::io::Write;
#[post("/<path..>", data="<text>")]
fn write_utf8_to(path: std::path::PathBuf, text: Vec<u8>) -> rocket_anyhow::Result {
let mut file = std::fs::File::open(path)?;
let text = std::str::from_utf8(&text)?;
file.write_all(text.as_ref())?;
Ok(())
}