provide config:path function for env-overridable paths (like log-path)
This commit is contained in:
parent
1ec80a559f
commit
3217a16002
4 changed files with 9 additions and 4 deletions
|
@ -14,6 +14,6 @@
|
|||
:routes
|
||||
`((("api") server:message-handler)
|
||||
(() server:fileserver :doc-root
|
||||
,(util:absolute-dir (config:from-env :docroot "/var/www/html")))))
|
||||
;,(config:directory "/var/www/html" :env :docroot)
|
||||
;,(util:path-from-string (config:from-env :docroot "/var/www/html/")))))
|
||||
,(config:path "/var/www/html/" :env-key :docroot))))
|
||||
(config:add-action '(:test :data) #'core:echo)
|
||||
|
|
|
@ -4,8 +4,9 @@
|
|||
|
||||
(defpackage :scopes/config
|
||||
(:use :common-lisp)
|
||||
(:local-nicknames (:util :scopes/util))
|
||||
(:export #:base #:root #:*root* #:*current*
|
||||
#:env-data #:env-keys #:env-prefix #:env-path #:from-env
|
||||
#:env-data #:env-keys #:env-prefix #:env-path #:from-env #:path
|
||||
#:actions #:add #:add-action #:children #:env-slots
|
||||
#:name #:setup #:parent #:shutdown))
|
||||
|
||||
|
@ -90,6 +91,9 @@
|
|||
(defun from-env (key default)
|
||||
(or (gethash key (env-data *root*)) default))
|
||||
|
||||
(defun path (s &key env-key)
|
||||
(util:path-from-string (from-env env-key s)))
|
||||
|
||||
(defun hash-to-slots (ht obj slots)
|
||||
(if ht
|
||||
(dolist (sl slots)
|
||||
|
|
|
@ -76,12 +76,13 @@
|
|||
(tail (last message-head)))
|
||||
(if (string= (car tail) "")
|
||||
(setf (car tail) "index.html"))
|
||||
(log:debug "doc-root: ~s" doc-root)
|
||||
(let* ((rel-path (str:join "/" message-head))
|
||||
(file-app (make-instance 'lack/app/file:lack-app-file
|
||||
:file rel-path :root doc-root)))
|
||||
(lack/component:call file-app env))))
|
||||
|
||||
(defun message-handler (ctx env)
|
||||
(defun message-handler (ctx env &key html-renderer)
|
||||
(let* ((iact (make-instance 'interaction))
|
||||
(msg (message:create
|
||||
(head env) :data (plist (post-data env)) :sender iact))
|
||||
|
|
Loading…
Add table
Reference in a new issue