mirror of
https://github.com/eliasrenman/url-shortener.git
synced 2026-03-16 20:16:06 +01:00
9 lines
290 B
Rust
9 lines
290 B
Rust
use rocket::{http::Status, response::Redirect};
|
|
|
|
use crate::db::url::get_entry;
|
|
|
|
pub fn handle_redirect(url: &str) -> Result<Redirect, (Status, &'static str)> {
|
|
let row = get_entry(url).map_err(|_| (Status::NotFound, "Redirect Not found"))?;
|
|
Ok(Redirect::to(row.destination_url))
|
|
}
|