[hunchentoot-devel] Specializing process-request
Frode V. Fjeld
frode at netfonds.no
Wed Nov 25 10:23:25 UTC 2009
frode at netfonds.no (Frode V. Fjeld) writes:
> (I can/could of course specialize process-request for my acceptor class
> using an unqualified method, and thus set up the dynamic environment
> just how I want it. However I would then just have to copy the full body
> of the standard process-request to insert a line or two inside the body
> of the handler-bind. I believe it's the purpose of a processing protocol
> to avoid having to do such things.)
This didn't really work out in practice: cut'n'pasting the body of
process-request into a different package made it clear that
process-request can't really be replaced without breaking lots of
stuff. Also, modifying my dispatchers or handlers proved to be
impractical. So here's a diff detailing my suggestion in my previous
posting. It's simple, and seems to work well.
Index: packages.lisp
===================================================================
--- packages.lisp (revision 4474)
+++ packages.lisp (working copy)
@@ -168,6 +168,7 @@
"DELETE-AUX-REQUEST-VALUE"
"DELETE-SESSION-VALUE"
"DISPATCH-EASY-HANDLERS"
+ "DISPATCH-REQUEST"
"ESCAPE-FOR-HTML"
"EXECUTE-ACCEPTOR"
"GET-PARAMETER"
Index: request.lisp
===================================================================
--- request.lisp (revision 4474)
+++ request.lisp (working copy)
@@ -210,6 +210,10 @@
;; we assume it's not our fault...
(setf (return-code*) +http-bad-request+)))))
+(defmethod dispatch-request (request)
+ (funcall (acceptor-request-dispatcher *acceptor*)
+ request))
+
(defmethod process-request (request)
"Standard implementation for processing a request. You should not
change or replace this functionality unless you know what you're
@@ -227,7 +231,7 @@
;; skip dispatch if bad request
(when (eql (return-code *reply*) +http-ok+)
;; now do the work
- (funcall (acceptor-request-dispatcher *acceptor*) *request*)))))
+ (dispatch-request request)))))
(when error
(setf (return-code *reply*)
+http-internal-server-error+))
--
Frode V. Fjeld
Netfonds Bank ASA
More information about the Tbnl-devel
mailing list