|
@@ -9,6 +9,7 @@
|
|
|
'(("/media/pogo/Music/" . "/music/")) "Map database paths to urls")
|
|
'(("/media/pogo/Music/" . "/music/")) "Map database paths to urls")
|
|
|
|
|
|
|
|
(defun get-url (path)
|
|
(defun get-url (path)
|
|
|
|
|
+ (declare #.*standard-optimize-settings*)
|
|
|
(when (and path (pathnamep path))
|
|
(when (and path (pathnamep path))
|
|
|
(let ((path (namestring path)))
|
|
(let ((path (namestring path)))
|
|
|
(loop for (path-prefix . url-prefix) in *path-url-mappings*
|
|
(loop for (path-prefix . url-prefix) in *path-url-mappings*
|
|
@@ -128,6 +129,13 @@
|
|
|
(200-json (query-tracks (car *db*)
|
|
(200-json (query-tracks (car *db*)
|
|
|
:restrictions `((id . ,(getf params :id))))))
|
|
:restrictions `((id . ,(getf params :id))))))
|
|
|
|
|
|
|
|
|
|
+(defun file-server (root)
|
|
|
|
|
+ (lambda (params)
|
|
|
|
|
+ (declare #.*standard-optimize-settings*)
|
|
|
|
|
+ (let ((file (probe-file (cl-fad:merge-pathnames-as-file
|
|
|
|
|
+ root (car (getf params :splat))))))
|
|
|
|
|
+ (if file (list 200 nil file) +404+))))
|
|
|
|
|
+
|
|
|
(defvar *mapper* (myway:make-mapper))
|
|
(defvar *mapper* (myway:make-mapper))
|
|
|
(myway:connect *mapper* "/cat/:category/size" 'get-category-size)
|
|
(myway:connect *mapper* "/cat/:category/size" 'get-category-size)
|
|
|
(myway:connect *mapper* "/cat/:category" 'get-category)
|
|
(myway:connect *mapper* "/cat/:category" 'get-category)
|
|
@@ -135,7 +143,11 @@
|
|
|
(myway:connect *mapper* "/album/:id/tracks" 'album-tracks)
|
|
(myway:connect *mapper* "/album/:id/tracks" 'album-tracks)
|
|
|
;;(myway:connect *mapper* "*" (lambda (p) (declare (ignore p)) +404+))
|
|
;;(myway:connect *mapper* "*" (lambda (p) (declare (ignore p)) +404+))
|
|
|
|
|
|
|
|
-(defun main (&rest args &key (port 5000) (debug nil) (use-thread t) &allow-other-keys)
|
|
|
|
|
|
|
+(defun main (&rest args &key (port 5000) (debug nil) (use-thread t) (serve-files t) &allow-other-keys)
|
|
|
|
|
+ (when serve-files
|
|
|
|
|
+ (loop for (path-prefix . url-prefix) in *path-url-mappings*
|
|
|
|
|
+ do (myway:connect *mapper* (concatenate 'string url-prefix "*")
|
|
|
|
|
+ (file-server path-prefix))))
|
|
|
(apply #'clack:clackup
|
|
(apply #'clack:clackup
|
|
|
(myway:to-app *mapper*)
|
|
(myway:to-app *mapper*)
|
|
|
:server :woo
|
|
:server :woo
|