From 7d5c70ddd6d502c31f8c59e0f04118b674eaeb7a Mon Sep 17 00:00:00 2001 From: Jade Date: Fri, 17 Feb 2023 22:32:21 +0100 Subject: [PATCH] Some documentation and cleanup of old, commented out code. Signed-off-by: Jade --- src/endpoints/create.rs | 1 + src/endpoints/info.rs | 1 + src/endpoints/pasta.rs | 3 +++ src/endpoints/pastalist.rs | 1 + src/endpoints/qr.rs | 1 + src/endpoints/remove.rs | 1 + src/endpoints/static_resources.rs | 42 ------------------------------- 7 files changed, 8 insertions(+), 42 deletions(-) diff --git a/src/endpoints/create.rs b/src/endpoints/create.rs index 2a627c7..fdf91e7 100644 --- a/src/endpoints/create.rs +++ b/src/endpoints/create.rs @@ -27,6 +27,7 @@ pub async fn index() -> impl Responder { .body(IndexTemplate { args: &ARGS }.render().unwrap()) } +/// Pasta creation endpoint. pub async fn create( data: web::Data, mut payload: Multipart, diff --git a/src/endpoints/info.rs b/src/endpoints/info.rs index 9ae4d86..98e44f4 100644 --- a/src/endpoints/info.rs +++ b/src/endpoints/info.rs @@ -14,6 +14,7 @@ struct Info<'a> { message: &'a str, } +/// Endpoint to get information about the instance. #[get("/info")] pub async fn info(data: web::Data) -> HttpResponse { // get access to the pasta collection diff --git a/src/endpoints/pasta.rs b/src/endpoints/pasta.rs index d490649..28978f0 100644 --- a/src/endpoints/pasta.rs +++ b/src/endpoints/pasta.rs @@ -18,6 +18,7 @@ struct PastaTemplate<'a> { args: &'a Args, } +/// Endpoint to view a pasta. #[get("/pasta/{id}")] pub async fn getpasta(data: web::Data, id: web::Path) -> HttpResponse { // get access to the pasta collection @@ -82,6 +83,7 @@ pub async fn getpasta(data: web::Data, id: web::Path) -> HttpR .body(ErrorTemplate { args: &ARGS }.render().unwrap()) } +/// Endpoint for redirection. #[get("/url/{id}")] pub async fn redirecturl(data: web::Data, id: web::Path) -> HttpResponse { // get access to the pasta collection @@ -149,6 +151,7 @@ pub async fn redirecturl(data: web::Data, id: web::Path) -> Ht .body(ErrorTemplate { args: &ARGS }.render().unwrap()) } +/// Endpoint to request pasta as raw file. #[get("/raw/{id}")] pub async fn getrawpasta(data: web::Data, id: web::Path) -> String { // get access to the pasta collection diff --git a/src/endpoints/pastalist.rs b/src/endpoints/pastalist.rs index 67bdc80..0ff15e4 100644 --- a/src/endpoints/pastalist.rs +++ b/src/endpoints/pastalist.rs @@ -13,6 +13,7 @@ struct PastaListTemplate<'a> { args: &'a Args, } +/// The endpoint to view all currently registered pastas. #[get("/pastalist")] pub async fn list(data: web::Data) -> HttpResponse { if ARGS.no_listing { diff --git a/src/endpoints/qr.rs b/src/endpoints/qr.rs index 7cbe6af..4fe799b 100644 --- a/src/endpoints/qr.rs +++ b/src/endpoints/qr.rs @@ -16,6 +16,7 @@ struct QRTemplate<'a> { args: &'a Args, } +/// Endpoint to open a QR code to a pasta. #[get("/qr/{id}")] pub async fn getqr(data: web::Data, id: web::Path) -> HttpResponse { // get access to the pasta collection diff --git a/src/endpoints/remove.rs b/src/endpoints/remove.rs index 936e1e2..fc99c0f 100644 --- a/src/endpoints/remove.rs +++ b/src/endpoints/remove.rs @@ -10,6 +10,7 @@ use crate::AppState; use askama::Template; use std::fs; +/// Endpoint to remove a pasta. #[get("/remove/{id}")] pub async fn remove(data: web::Data, id: web::Path) -> HttpResponse { if ARGS.readonly { diff --git a/src/endpoints/static_resources.rs b/src/endpoints/static_resources.rs index e82fc6e..bb738f4 100644 --- a/src/endpoints/static_resources.rs +++ b/src/endpoints/static_resources.rs @@ -19,45 +19,3 @@ fn handle_embedded_file(path: &str) -> HttpResponse { async fn static_resources(path: web::Path) -> impl Responder { handle_embedded_file(path.as_str()) } - -// #[derive(Template)] -// #[template(path = "water.css", escape = "none")] -// struct WaterCSS<'a> { -// _marker: PhantomData<&'a ()>, -// } - -// // #[derive(Template)] -// // #[template(path = "logo.png", escape = "none")] -// struct LogoPNG<'a> { -// _marker: PhantomData<&'a ()>, -// } - -// #[derive(Template)] -// #[template(path = "favicon.svg", escape = "none")] -// struct Favicon<'a> { -// _marker: PhantomData<&'a ()>, -// } - -// #[get("/static/{resource}")] -// pub async fn static_resources(resource_id: web::Path) -> HttpResponse { -// match resource_id.into_inner().as_str() { -// "water.css" => HttpResponse::Ok().content_type("text/css").body( -// WaterCSS { -// _marker: Default::default(), -// } -// .render() -// .unwrap(), -// ), -// "logo.png" => HttpResponse::Ok() -// .content_type("image/png") -// .body(Ok(EmbedFile::open("templates/logo.png")?)), -// "favicon.svg" => HttpResponse::Ok().content_type("image/svg+xml").body( -// Favicon { -// _marker: Default::default(), -// } -// .render() -// .unwrap(), -// ), -// _ => HttpResponse::NotFound().content_type("text/html").finish(), -// } -// }