use axum::{ extract::{Path, State}, http::StatusCode, response::Redirect, }; use sqlx::SqlitePool; use crate::paste::PasteType; pub async fn get_redirect( State(db): State, Path(id): Path, ) -> Result { let url = sqlx::query_scalar::<_, String>("SELECT content FROM notes WHERE type = ? AND id = ?") .bind(PasteType::UrlV1) .bind(id) .fetch_optional(&db) .await .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)? .ok_or(StatusCode::NOT_FOUND)?; Ok(Redirect::temporary(&url)) }