added customizability for /pasta/, /url/ and /raw/ endpoints

This commit is contained in:
Schrottkatze 2023-02-27 00:18:00 +01:00
parent f352129c78
commit 51751e3ee2
5 changed files with 31 additions and 10 deletions

View file

@ -197,6 +197,6 @@ pub async fn create(
CONVERTER.to_names(id)
};
Ok(HttpResponse::Found()
.append_header(("Location", format!("{}/pasta/{}", ARGS.public_path, slug)))
.append_header(("Location", format!("{}/{}/{}", ARGS.public_path, ARGS.pasta_endpoint, slug)))
.finish())
}

View file

@ -19,7 +19,6 @@ struct PastaTemplate<'a> {
}
/// Endpoint to view a pasta.
#[get("/pasta/{id}")]
pub async fn getpasta(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
// get access to the pasta collection
let mut pastas = data.pastas.lock().await;
@ -84,7 +83,6 @@ pub async fn getpasta(data: web::Data<AppState>, id: web::Path<String>) -> HttpR
}
/// Endpoint for redirection.
#[get("/url/{id}")]
pub async fn redirecturl(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
// get access to the pasta collection
let mut pastas = data.pastas.lock().await;
@ -152,7 +150,6 @@ pub async fn redirecturl(data: web::Data<AppState>, id: web::Path<String>) -> Ht
}
/// Endpoint to request pasta as raw file.
#[get("/raw/{id}")]
pub async fn getrawpasta(data: web::Data<AppState>, id: web::Path<String>) -> String {
// get access to the pasta collection
let mut pastas = data.pastas.lock().await;