This commit is contained in:
maurice committed 2026-11-14 17:25:55 +01:00
1 parent 377bd1e198
commit 139404b70f
17 files changed
+672 -48

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
use axum::{
extract::{Path, State},
http::StatusCode,
response::Redirect,
};
use sqlx::SqlitePool;
use crate::paste::PasteType;
pub async fn get_redirect(
State(db): State<SqlitePool>,
Path(id): Path<String>,
) -> Result<Redirect, StatusCode> {
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))
}