mirror of https://github.com/rwf2/Rocket.git
Add missing explicit lifetime parameter to `PasteId<'_>` in pastebin guide.
This commit is contained in:
parent
83a7fc48d2
commit
2040693dab
|
@ -414,12 +414,13 @@ the `retrieve` route, preventing attacks on the `retrieve` route:
|
|||
```rust
|
||||
# #[macro_use] extern crate rocket;
|
||||
|
||||
# use std::borrow::Cow;
|
||||
# use rocket::tokio::fs::File;
|
||||
|
||||
# type PasteId = usize;
|
||||
# type PasteId<'a> = Cow<'a, str>;
|
||||
|
||||
#[get("/<id>")]
|
||||
async fn retrieve(id: PasteId) -> Option<File> {
|
||||
async fn retrieve(id: PasteId<'_>) -> Option<File> {
|
||||
let filename = format!("upload/{id}", id = id);
|
||||
File::open(&filename).await.ok()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue