mirror of
https://github.com/eliasrenman/url-shortener.git
synced 2026-03-16 20:16:06 +01:00
first commit
This commit is contained in:
8
src/handlers/url.rs
Normal file
8
src/handlers/url.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
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))
|
||||
}
|
||||
Reference in New Issue
Block a user