Additional changes to prev. commit

This commit is contained in:
Daniel Szabo 2022-06-04 22:21:22 +01:00
parent fe013d9d85
commit ff921dc103
2 changed files with 5 additions and 3 deletions

View file

@ -54,7 +54,7 @@ pub async fn redirecturl(data: web::Data<AppState>, id: web::Path<String>) -> Ht
for pasta in pastas.iter() { for pasta in pastas.iter() {
if pasta.id == id { if pasta.id == id {
if pasta.pasta_type == "url" { if pasta.pasta_type == "url" {
return HttpResponse::Ok() return HttpResponse::Found()
.append_header(("Location", String::from(&pasta.content))) .append_header(("Location", String::from(&pasta.content)))
.finish(); .finish();
} else { } else {

View file

@ -10,7 +10,9 @@ use askama::Template;
#[get("/remove/{id}")] #[get("/remove/{id}")]
pub async fn remove(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse { pub async fn remove(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
if ARGS.readonly { if ARGS.readonly {
return HttpResponse::Ok().append_header(("Location", "/")).finish(); return HttpResponse::Found()
.append_header(("Location", "/"))
.finish();
} }
let mut pastas = data.pastas.lock().unwrap(); let mut pastas = data.pastas.lock().unwrap();
@ -22,7 +24,7 @@ pub async fn remove(data: web::Data<AppState>, id: web::Path<String>) -> HttpRes
for (i, pasta) in pastas.iter().enumerate() { for (i, pasta) in pastas.iter().enumerate() {
if pasta.id == id { if pasta.id == id {
pastas.remove(i); pastas.remove(i);
return HttpResponse::Ok() return HttpResponse::Found()
.append_header(("Location", "/pastalist")) .append_header(("Location", "/pastalist"))
.finish(); .finish();
} }