(defun serve-static ()
"Handle a request for a file under static/ directory"
- (let* ((script-name (script-name))
+ (let* ((script-name (hunchentoot:script-name hunchentoot:*request*))
(fname (subseq script-name (length +static-web-root+)))
(fullname (concatenate 'string +static-files-root+ fname)))
- (handle-static-file fullname)))
+ (hunchentoot:handle-static-file fullname)))
(defclass session ()
((update-queue
(defvar *empire-session*)
(defmacro with-session (&body body)
- `(let ((*empire-session* (session-value 'session)))
+ `(let ((*empire-session* (hunchentoot:session-value 'session)))
(if *empire-session*
(progn ,@body)
- (redirect +login-page+))))
+ (hunchentoot:redirect +login-page+))))
(defun update ()
"Send stream of updates to client"
;; destination of login-form
(defun login-action ()
(handler-case
- (let* ((user (post-parameter "username"))
- (pass (post-parameter "password"))
+ (let* ((user (hunchentoot:post-parameter "username"))
+ (pass (hunchentoot:post-parameter "password"))
(session (make-session user pass)))
- (setf (session-value 'session) session)
+ (setf (hunchentoot:session-value 'session) session)
(empire-log:info "~a: User ~a logging in." session user)
- (redirect +root-url+))
+ (hunchentoot:redirect +root-url+))
(usocket:connection-refused-error (e)
(format nil "Connection error: ~a~%" e))))
(defun command-action ()
(with-session
- (empire:command (connection *empire-session*) (get-parameter "q"))))
+ (empire:command (connection *empire-session*) (hunchentoot:get-parameter "q"))
+ "ok"))
(defun root-page ()
(with-session
- (handle-static-file (concatenate 'string +static-files-root+ +root-page-file+))))
+ (hunchentoot:handle-static-file (concatenate 'string +static-files-root+ +root-page-file+))))
(defun dispatch (request)
- (let ((script-name (script-name request)))
+ (let ((script-name (hunchentoot:script-name request)))
(cond
((not (string-starts-with script-name +web-root+)) nil) ; do not handle this request
((string= script-name "/eow/update") 'update)
(defun start ()
(empire-log:info "Startup")
- (pushnew 'dispatch *dispatch-table* :test #'eq))
-
+ (pushnew 'dispatch hunchentoot:*dispatch-table* :test #'eq))