Add use-default-middlewares option to lackup (The default is T).

This commit is contained in:
Eitaro Fukamachi 2015-03-13 15:56:14 +09:00
parent 627141bbe9
commit 4359497b3e

View file

@ -13,22 +13,47 @@
:builder))
(in-package :lack)
(defun eval-file (file)
"Safer way to read and eval a file content. This function returns the last value."
(check-type file (or pathname string))
(with-open-file (in file)
(let ((*package* *package*)
(*readtable* *readtable*)
(*load-pathname* nil)
(*load-truename* nil))
(loop with results
with eof = '#:eof
for form = (read in nil eof)
until (eq form eof)
do (setf results (multiple-value-list (eval form)))
finally
(return (apply #'values results))))))
(defun lackup (app &rest args
&key (server :hunchentoot)
(port 5000)
(debug t)
silent
(use-thread #+thread-support t #-thread-support nil)
(use-default-middlewares t)
&allow-other-keys)
(flet ((start-message ()
(flet ((print-start-message ()
(unless silent
(format t "~&~:(~A~) server is started.~%Listening on localhost:~A.~%" server port))))
(format t "~&~:(~A~) server is started.~%Listening on localhost:~A.~%" server port)))
(buildapp (app)
(let ((app (etypecase app
((or pathname string)
(eval-file app))
(function app))))
(if use-default-middlewares
(builder :backtrace app)
app))))
(unless use-thread
(start-message))
(print-start-message))
(prog1
(apply #'lack.handler:run app server
(apply #'lack.handler:run (buildapp app) server
:port port
:debug debug
:use-thread use-thread
(delete-from-plist args :server :port :debug :silent :use-thread))
(start-message))))
(print-start-message))))