From: Gerd Flaig Date: Sun, 22 Mar 2009 14:40:07 +0000 (+0100) Subject: Adapt to hunchentoot 1.0 API X-Git-Url: http://git.pond.sub.org/?p=eow;a=commitdiff_plain;h=93ee0f65819529e7361cfc585c6509a045e4344b;ds=sidebyside Adapt to hunchentoot 1.0 API --- diff --git a/package.lisp b/package.lisp index 6f54805..5ba1030 100644 --- a/package.lisp +++ b/package.lisp @@ -16,7 +16,7 @@ (:use :cl :sb-thread) (:export :create :enqueue :dequeue)) (defpackage :empire-web - (:use :cl :hunchentoot) + (:use :cl) (:export :start :send :prompt :data)) (defpackage :empire-log (:use :cl) diff --git a/setup.lisp b/setup.lisp index 5a16184..6d9e6a9 100644 --- a/setup.lisp +++ b/setup.lisp @@ -1,7 +1,9 @@ (mb:load "eow") -(setf *webserver* (hunchentoot:start-server :port 4242)) +(setf *webserver* + (hunchentoot:start (make-instance 'hunchentoot:acceptor :port 4242))) ;; (hunchentoot:stop-server *webserver*) -(setf hunchentoot:*show-lisp-backtraces-p* t) +;(setf hunchentoot:*show-lisp-backtraces-p* t) (setf hunchentoot:*show-lisp-errors-p* t) -(setf hunchentoot:*catch-errors-p* nil) (empire-web:start) +;(setf *break-on-signals* 'error) +;(setf *break-on-signals* nil) diff --git a/web.lisp b/web.lisp index 556fbf4..96fcb29 100644 --- a/web.lisp +++ b/web.lisp @@ -27,10 +27,10 @@ (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 @@ -56,10 +56,10 @@ (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" @@ -79,26 +79,26 @@ ;; 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) @@ -111,5 +111,4 @@ (defun start () (empire-log:info "Startup") - (pushnew 'dispatch *dispatch-table* :test #'eq)) - + (pushnew 'dispatch hunchentoot:*dispatch-table* :test #'eq))