app/deme (fileserver): minor improvements, provide util:absolute-dir for docroot
This commit is contained in:
parent
9da223abc6
commit
04cce1ded4
3 changed files with 16 additions and 17 deletions
|
@ -5,13 +5,11 @@
|
||||||
(config:root :env-keys '(:docroot :address :port)
|
(config:root :env-keys '(:docroot :address :port)
|
||||||
:env-path (util:runtime-path ".env"))
|
:env-path (util:runtime-path ".env"))
|
||||||
|
|
||||||
(config:add :server :class 'server:config
|
(config:add :server
|
||||||
|
:class 'server:config
|
||||||
:port "8800"
|
:port "8800"
|
||||||
:address "0.0.0.0"
|
:address "0.0.0.0"
|
||||||
:routes
|
:routes
|
||||||
`((("api") server:message-handler)
|
`((("api") server:message-handler)
|
||||||
(() server:fileserver
|
(() server:fileserver :doc-root
|
||||||
:doc-root
|
,(util:absolute-dir (config:from-env :docroot "/var/www/html")))))
|
||||||
,(make-pathname
|
|
||||||
:directory (list :absolute (config:from-env :docroot "/var/www"))))))
|
|
||||||
;,(util:home-path "" "hugo" "0-public" "scopes" "hx"))))
|
|
||||||
|
|
|
@ -48,14 +48,12 @@
|
||||||
(let* ((key (str:concat prefix (string sl)))
|
(let* ((key (str:concat prefix (string sl)))
|
||||||
(env-val (uiop:getenv key))
|
(env-val (uiop:getenv key))
|
||||||
(dotenv-val (if dotenv-data (gethash key dotenv-data))))
|
(dotenv-val (if dotenv-data (gethash key dotenv-data))))
|
||||||
(format t "~&init after config:root key: ~s, env-val ~s~%"
|
;(format t "~&init after config:root key: ~s, env-val ~s~%" key dotenv-val)
|
||||||
key dotenv-val)
|
|
||||||
(if env-val
|
(if env-val
|
||||||
(setf (gethash sl data) env-val)
|
(setf (gethash sl data) env-val)
|
||||||
(setf (gethash sl data) dotenv-val))))))
|
(setf (gethash sl data) dotenv-val))))))
|
||||||
|
|
||||||
(defun root (&rest params &key (class 'root) &allow-other-keys)
|
(defun root (&rest params &key (class 'root) &allow-other-keys)
|
||||||
(format t "~&config:root params: ~s~%" params)
|
|
||||||
(setf *root* (apply #'make-instance class params)))
|
(setf *root* (apply #'make-instance class params)))
|
||||||
|
|
||||||
;;;; config base class
|
;;;; config base class
|
||||||
|
|
11
util.lisp
11
util.lisp
|
@ -1,13 +1,13 @@
|
||||||
;;;; clscopes/util
|
;;;; cl-scopes/util - common utilities for the scopes project
|
||||||
|
|
||||||
;;;; Common utilities for the scopes project.
|
|
||||||
|
|
||||||
(defpackage :scopes/util
|
(defpackage :scopes/util
|
||||||
(:use :common-lisp)
|
(:use :common-lisp)
|
||||||
(:export #:home-path #:relative-path #:runtime-path #:system-path))
|
(:export #:absolute-dir #:home-path #:relative-path #:runtime-path #:system-path))
|
||||||
|
|
||||||
(in-package :scopes/util)
|
(in-package :scopes/util)
|
||||||
|
|
||||||
|
;;;; directory and pathname utilities
|
||||||
|
|
||||||
(defun split-filename (name)
|
(defun split-filename (name)
|
||||||
(let* ((parts (str:rsplit "." name :limit 2))
|
(let* ((parts (str:rsplit "." name :limit 2))
|
||||||
(n (car parts))
|
(n (car parts))
|
||||||
|
@ -17,6 +17,9 @@
|
||||||
(setf type nil))
|
(setf type nil))
|
||||||
(values n type)))
|
(values n type)))
|
||||||
|
|
||||||
|
(defun absolute-dir (path)
|
||||||
|
(make-pathname :directory (list :absolute path)))
|
||||||
|
|
||||||
(defun relative-path (name &rest dirs)
|
(defun relative-path (name &rest dirs)
|
||||||
(multiple-value-bind (n type) (split-filename name)
|
(multiple-value-bind (n type) (split-filename name)
|
||||||
(make-pathname :name n :type type :directory (cons :relative dirs))))
|
(make-pathname :name n :type type :directory (cons :relative dirs))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue