mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
clog-connection:add-plugin-path
This commit is contained in:
parent
4bcbc646fc
commit
95ce3a89e7
2 changed files with 19 additions and 0 deletions
|
|
@ -396,6 +396,8 @@ the contents sent to the brower."
|
|||
(,*compiled-boot-js*)))
|
||||
((ppcre:scan "^(?:/clog$)" path)
|
||||
(clog-server env))
|
||||
((plugin-path path)
|
||||
(lack/middleware/static::call-app-file (plugin-path path) env))
|
||||
(t
|
||||
(lack/middleware/static::call-app-file *static-root* env)))))))
|
||||
;; Wrap lack middlewares
|
||||
|
|
@ -426,6 +428,19 @@ the contents sent to the brower."
|
|||
(format t "Boot file for path / : ~A~%" boot-file)
|
||||
*client-handler*)
|
||||
|
||||
(defun add-plugin-path (regex static-path)
|
||||
"When a path to the webserver matches REGEX resolve the static file using
|
||||
STATIC-PATH"
|
||||
(setf (gethash regex *plugin-paths*) static-path))
|
||||
|
||||
(defun plugin-path (path)
|
||||
(block ret-static-path
|
||||
(maphash (lambda (k v)
|
||||
(when (ppcre:scan k path)
|
||||
(return-from ret-static-path v)))
|
||||
*plugin-paths*)
|
||||
nil))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; shutdown-connection ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ script."
|
|||
(*reconnect-delay* variable)
|
||||
(*static-root* variable)
|
||||
(*clog-port* variable)
|
||||
(*plugin-paths* variable)
|
||||
|
||||
(initialize function)
|
||||
(random-port function)
|
||||
|
|
@ -49,6 +50,7 @@ script."
|
|||
(set-clog-path function)
|
||||
(get-connection-data function)
|
||||
(delete-connection-data function)
|
||||
(add-plugin-path function)
|
||||
|
||||
"CLOG system utilities"
|
||||
|
||||
|
|
@ -93,6 +95,8 @@ script."
|
|||
(defvar *reconnect-delay* 7 "Time to delay in seconds for possible reconnect (default 7)")
|
||||
(defparameter *static-root* nil "Contains the static-root setting after initialization.")
|
||||
(defparameter *clog-port* 8080 "Port this instance of clog was started on")
|
||||
(defvar *plugin-paths* (make-hash-table* :test #'equalp) "Path regex -> static-root")
|
||||
|
||||
|
||||
(defvar *on-connect-handler* nil "New connection event handler.")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue