X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=project.lisp;h=ea38c8a28c54618dd74e0314092b0559e7bf0c28;hb=ba01a7216c7a4c15c103525654fe10ea5845afb1;hp=a6a00feb24437f3bce28741dd984aebc1e83946a;hpb=ca586910648f4844e335d92f23e619fd2b84f969;p=wol.git diff --git a/project.lisp b/project.lisp index a6a00fe..ea38c8a 100644 --- a/project.lisp +++ b/project.lisp @@ -7,7 +7,7 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: July 2003 ;;;; -;;;; $Id: project.lisp,v 1.13 2003/08/10 17:56:44 kevin Exp $ +;;;; $Id$ ;;;; ;;;; This file and Wol are Copyright (c) 2001-2003 by Kevin M. Rosenberg ;;;; ************************************************************************* @@ -45,7 +45,7 @@ (let ((hash (make-hash-table :size (length map) :test 'equal))) (dolist (map-item map) - (setf (gethash (first map-item) hash) (second map-item))) + (setf (gethash (first map-item) hash) (cdr map-item))) (setf (project-hash-map project) hash)) (ecase connector @@ -222,36 +222,45 @@ (defun dispatch-to-handler (req ent) - (let ((handler (request-find-handler req ent)) + (let ((handlers (request-find-handlers req ent)) (*wol-stream* (request-socket req))) - (if handler - (handle-request handler req ent) + (if handlers + (handle-request handlers req ent) (no-url-handler req ent)))) -(defun request-find-handler (req ent) +(defun request-find-handlers (req ent) (nth-value 0 (gethash (request-page req) (project-hash-map (entity-project ent))))) -(defun handle-request (handler req ent) - (typecase handler +(defun handle-request (handlers req ent) + (typecase handlers (null + (setf (entity-generators ent) nil) nil) - ((or symbol function) - (when (and (symbolp handler) - (not (fboundp handler))) - (cmsg "handler given a symbol without a function ~S" handler) - (return-from handle-request nil)) - (let ((next-page (funcall handler req ent))) - (typecase next-page - (string - (redirect-entity next-page req ent)) - (cons - (redirect-entity (car next-page) req ent (cadr next-page))) - (null - t) - (t - (cmsg "handler should return nil or a string, not ~S" next-page)))) - t) + (list + (let ((next-handler (first handlers))) + (setf (entity-generators ent) (cdr handlers)) + (when (and (symbolp next-handler) + (not (fboundp next-handler))) + (cmsg "handler given a symbol without a function ~S" next-handler) + (return-from handle-request nil)) + (let ((next-page (funcall next-handler req ent))) + (typecase next-page + (string + (setf (entity-generators ent) nil) + (redirect-entity next-page req ent)) + (cons + (setf (entity-generators ent) nil) + (redirect-entity (car next-page) req ent (cadr next-page))) + (keyword + (if (eq :continue next-page) + (handle-request (cdr handlers) req ent) + (add-log-entry "Invalid return keyword ~S" next-page))) + (null + t) + (t + (cmsg "handler should return nil or a string, not ~S" next-page)))) + t)) (string (cmsg "string handler not supported: ~A" handler) nil) @@ -309,7 +318,7 @@ (net.aserve:with-http-response ((aserve-request ,req) (entity-aserve-entity ,ent) - :content-type (ml::format-string ,format) + :content-type (ml::format->string ,format) :timeout ,timeout :response (case ,response-code @@ -351,7 +360,7 @@ ,result ,outstr ,stream) (declare (ignorable ,stream)) (write-header-line "Status" ,response-string) - (write-header-line "Content-Type" (ml::format-string ,fmt)) + (write-header-line "Content-Type" (ml::format->string ,fmt)) (dolist (,hdr ,headers) (write-header-line (car ,hdr) (cdr ,hdr))) (unless ,precomp