From 660092480b858c2f34cc9c947105361ade233ddb Mon Sep 17 00:00:00 2001 From: colin Date: Fri, 26 May 2023 08:47:36 -0700 Subject: refactored images endpoint --- fussy.lisp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'fussy.lisp') diff --git a/fussy.lisp b/fussy.lisp index b7c8385..7416378 100644 --- a/fussy.lisp +++ b/fussy.lisp @@ -551,18 +551,19 @@ h1 { (or (uiop:file-exists-p (robots-path-name)) "")) +(defun theme-image-pathname (pkg theme img) + (uiop:ensure-pathname + (format nil "~a/~a/~a/~a" + (full-theme-image-directory) + pkg + theme + img))) + (lzb:defendpoint* :get "/images/:pkg:/:theme:/:image:" () () "Endpoint for serving theme preview images" - (let ((file-path - (pathname - (format nil "~a/~a/~a/~a" - (full-theme-image-directory) - pkg - theme - image)))) - (unless (uiop:file-exists-p file-path) - (lzb:http-err 404 "no such file")) - file-path)) + (a:if-let (file-path (theme-image-pathname pkg theme image)) + file-path + (lzb:http-err 404 "No such file"))) (defun a-string (s) s) -- cgit v1.2.3