]> git.pond.sub.org Git - eow/commitdiff
Adapt to hunchentoot 1.0 API
authorGerd Flaig <gefla@pond.sub.org>
Sun, 22 Mar 2009 14:40:07 +0000 (15:40 +0100)
committerGerd Flaig <gefla@pond.sub.org>
Sun, 22 Mar 2009 14:40:07 +0000 (15:40 +0100)
package.lisp
setup.lisp
web.lisp

index 6f54805a59dfc516e17993400f83156e2c1965df..5ba1030c80e277d95f858f7df7f32e1d2f252e6c 100644 (file)
@@ -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)
index 5a161845c909e30a351e44732f4b00621c235068..6d9e6a9edeb426ae348ac1487139bc43a385c0f8 100644 (file)
@@ -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)
index 556fbf4e24889ef15f4d553b62a0fa847d498f94..96fcb29d51da10120c0dd1e6a8004d6c03c5356d 100644 (file)
--- a/web.lisp
+++ b/web.lisp
 
 (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))