Some documentation and cleanup of old, commented out code.

Signed-off-by: Jade <obsidianical@gmail.com>
This commit is contained in:
Schrottkatze 2023-02-17 22:32:21 +01:00
parent 528a7b6899
commit 7d5c70ddd6
7 changed files with 8 additions and 42 deletions

View file

@ -27,6 +27,7 @@ pub async fn index() -> impl Responder {
.body(IndexTemplate { args: &ARGS }.render().unwrap()) .body(IndexTemplate { args: &ARGS }.render().unwrap())
} }
/// Pasta creation endpoint.
pub async fn create( pub async fn create(
data: web::Data<AppState>, data: web::Data<AppState>,
mut payload: Multipart, mut payload: Multipart,

View file

@ -14,6 +14,7 @@ struct Info<'a> {
message: &'a str, message: &'a str,
} }
/// Endpoint to get information about the instance.
#[get("/info")] #[get("/info")]
pub async fn info(data: web::Data<AppState>) -> HttpResponse { pub async fn info(data: web::Data<AppState>) -> HttpResponse {
// get access to the pasta collection // get access to the pasta collection

View file

@ -18,6 +18,7 @@ struct PastaTemplate<'a> {
args: &'a Args, args: &'a Args,
} }
/// Endpoint to view a pasta.
#[get("/pasta/{id}")] #[get("/pasta/{id}")]
pub async fn getpasta(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse { pub async fn getpasta(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
// get access to the pasta collection // get access to the pasta collection
@ -82,6 +83,7 @@ pub async fn getpasta(data: web::Data<AppState>, id: web::Path<String>) -> HttpR
.body(ErrorTemplate { args: &ARGS }.render().unwrap()) .body(ErrorTemplate { args: &ARGS }.render().unwrap())
} }
/// Endpoint for redirection.
#[get("/url/{id}")] #[get("/url/{id}")]
pub async fn redirecturl(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse { pub async fn redirecturl(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
// get access to the pasta collection // get access to the pasta collection
@ -149,6 +151,7 @@ pub async fn redirecturl(data: web::Data<AppState>, id: web::Path<String>) -> Ht
.body(ErrorTemplate { args: &ARGS }.render().unwrap()) .body(ErrorTemplate { args: &ARGS }.render().unwrap())
} }
/// Endpoint to request pasta as raw file.
#[get("/raw/{id}")] #[get("/raw/{id}")]
pub async fn getrawpasta(data: web::Data<AppState>, id: web::Path<String>) -> String { pub async fn getrawpasta(data: web::Data<AppState>, id: web::Path<String>) -> String {
// get access to the pasta collection // get access to the pasta collection

View file

@ -13,6 +13,7 @@ struct PastaListTemplate<'a> {
args: &'a Args, args: &'a Args,
} }
/// The endpoint to view all currently registered pastas.
#[get("/pastalist")] #[get("/pastalist")]
pub async fn list(data: web::Data<AppState>) -> HttpResponse { pub async fn list(data: web::Data<AppState>) -> HttpResponse {
if ARGS.no_listing { if ARGS.no_listing {

View file

@ -16,6 +16,7 @@ struct QRTemplate<'a> {
args: &'a Args, args: &'a Args,
} }
/// Endpoint to open a QR code to a pasta.
#[get("/qr/{id}")] #[get("/qr/{id}")]
pub async fn getqr(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse { pub async fn getqr(data: web::Data<AppState>, id: web::Path<String>) -> HttpResponse {
// get access to the pasta collection // get access to the pasta collection

View file

@ -10,6 +10,7 @@ use crate::AppState;
use askama::Template; use askama::Template;
use std::fs; use std::fs;
/// Endpoint to remove a pasta.
#[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 {

View file

@ -19,45 +19,3 @@ fn handle_embedded_file(path: &str) -> HttpResponse {
async fn static_resources(path: web::Path<String>) -> impl Responder { async fn static_resources(path: web::Path<String>) -> impl Responder {
handle_embedded_file(path.as_str()) 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<String>) -> 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(),
// }
// }