[hunchentoot-devel] Questions about using the same uri, but a different function for post and get methods.

rm at tuxteam.de rm at tuxteam.de
Tue Mar 29 09:38:03 UTC 2011


On Tue, Mar 29, 2011 at 01:19:55AM -0700, Jim Barrows wrote:
> I have a uri "/my-uri", when a get request is made I want to return whatever
> information I have, and when a post request made, I want to update that
> information.
> I had thought that doing this:
> 
> (define-easy-handler(get-business :uri "/business" :default-request-type
> :get)()
> (with-html-output-to-string (*standard-output* nil :prologue nil :indent t)
> (format t "{\"success\":true, \"data\": ~a}"
> (encode-json-plist-to-string (business::find-business)))))
> 
> (define-easy-handler(post-business :uri "/business" :default-request-type
> :post) (business-name)
> (with-html-output-to-string( *standard-output* nil :prologue nil :indent t)
> (format t "post-business - ~a" business-name)))
> 
> would accomplish that.  However, the second handler is always called, for
> the get and the post.
> I'm new to Lisp, and was wondering what I'm missing.
> Any help would be greatly appreciated.

I think you missunderstand the :default-request-type parameter. HT
doesn't dispatch on the request type, that parameter only decides where 
form parameters are taken from (unfortunately, I must say. Writing 
REST applications would be much easier with a dispatch on request method
and uri ...)


HTH Ralf Mattes

> -- 
> James A Barrows

> _______________________________________________
> tbnl-devel site list
> tbnl-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/tbnl-devel




More information about the Tbnl-devel mailing list