Friday, August 14, 2009

Servlet Support (wrapping servlets)

It would be nice to have the script able to call existing servlets, so they can be integrated easily.

The basic idea would be like:

;; foo.shp
(servlet "servlet.path")


Let's see how it would work:

(define (servlet! path (request ($request)) #:start (start 'start))
((dynamic-require path start) request))

Pretty straight forward!

The procedure allows loading of a servlet via dynamic-require, and it also offers the potential for you to rewrite the request before passing it to the servlet.

Now dynamic-require does not reload the servlet module when it changes, so that would be something we'll have to deal with in the future.

One thing you should make sure is that the servlet does not return an actual response object, as currently the code will not be converting the response object back so it can be wrapped by outer scripts. This is something we can attempt to address in the future. This means that if your servlet calls redirect-to, it will not work (you'll have to call redirect!).

No comments:

Post a Comment