Allow setting a public url for all paths
This commit is contained in:
parent
3ca89291dc
commit
a404f9a997
9 changed files with 52 additions and 28 deletions
|
@ -32,7 +32,7 @@ pub async fn create(
|
|||
) -> Result<HttpResponse, Error> {
|
||||
if ARGS.readonly {
|
||||
return Ok(HttpResponse::Found()
|
||||
.append_header(("Location", "/"))
|
||||
.append_header(("Location", format!("{}/", ARGS.public_path)))
|
||||
.finish());
|
||||
}
|
||||
|
||||
|
@ -154,6 +154,6 @@ pub async fn create(
|
|||
save_to_file(&pastas);
|
||||
|
||||
Ok(HttpResponse::Found()
|
||||
.append_header(("Location", format!("/pasta/{}", to_animal_names(id))))
|
||||
.append_header(("Location", format!("{}/pasta/{}", ARGS.public_path, to_animal_names(id))))
|
||||
.finish())
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ pub async fn get_edit(data: web::Data<AppState>, id: web::Path<String>) -> HttpR
|
|||
if pasta.id == id {
|
||||
if !pasta.editable {
|
||||
return HttpResponse::Found()
|
||||
.append_header(("Location", "/"))
|
||||
.append_header(("Location", format!("{}/", ARGS.public_path)))
|
||||
.finish();
|
||||
}
|
||||
return HttpResponse::Ok().content_type("text/html").body(
|
||||
|
@ -55,7 +55,7 @@ pub async fn post_edit(
|
|||
) -> Result<HttpResponse, Error> {
|
||||
if ARGS.readonly {
|
||||
return Ok(HttpResponse::Found()
|
||||
.append_header(("Location", "/"))
|
||||
.append_header(("Location", format!("{}/", ARGS.public_path)))
|
||||
.finish());
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ pub async fn post_edit(
|
|||
save_to_file(&pastas);
|
||||
|
||||
return Ok(HttpResponse::Found()
|
||||
.append_header(("Location", format!("/pasta/{}", pastas[i].id_as_animals())))
|
||||
.append_header(("Location", format!("{}/pasta/{}", ARGS.public_path, pastas[i].id_as_animals())))
|
||||
.finish());
|
||||
} else {
|
||||
break;
|
||||
|
|
|
@ -17,7 +17,7 @@ struct PastaListTemplate<'a> {
|
|||
pub async fn list(data: web::Data<AppState>) -> HttpResponse {
|
||||
if ARGS.no_listing {
|
||||
return HttpResponse::Found()
|
||||
.append_header(("Location", "/"))
|
||||
.append_header(("Location", format!("{}/", ARGS.public_path)))
|
||||
.finish();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use std::fs;
|
|||
pub async fn remove(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
|
||||
if ARGS.readonly {
|
||||
return HttpResponse::Found()
|
||||
.append_header(("Location", "/"))
|
||||
.append_header(("Location", format!("{}/", ARGS.public_path)))
|
||||
.finish();
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ pub async fn remove(data: web::Data<AppState>, id: web::Path<String>) -> HttpRes
|
|||
// remove it from in-memory pasta list
|
||||
pastas.remove(i);
|
||||
return HttpResponse::Found()
|
||||
.append_header(("Location", "/pastalist"))
|
||||
.append_header(("Location", format!("{}/pastalist", ARGS.public_path)))
|
||||
.finish();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue