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

Jim Barrows jim.barrows at gmail.com
Wed Mar 30 03:14:16 UTC 2011


I hadn't seen that.  Thanks!

On Tue, Mar 29, 2011 at 6:52 AM, Lou Vanek <lou.vanek at gmail.com> wrote:

> You can still dispatch on request method but you have to write a few
> lines of code.
>
> Did you look at the /info test example that comes with HT? Look at the
> 7th line of the table produced by this test URL. All the information
> is there that you need in order to perform a branch on request method.
>
>
> ::: URL: /localhost/info?abc=123
>
> Information Page
>
> This page has been called once since its handler was compiled.
>
> Some Information provides about this request:
>
> (HUNCHENTOOT:HOST)
>
>
>
> "localhost:8088"
>
> (HUNCHENTOOT:ACCEPTOR-ADDRESS WEB::*SERVER*)
>
>
>
> NIL
>
> (HUNCHENTOOT:ACCEPTOR-PORT WEB::*SERVER*)
>
>
>
> 8088
>
> (HUNCHENTOOT:REMOTE-ADDR*)
>
>
>
> "127.0.0.1"
>
> (HUNCHENTOOT:REMOTE-PORT*)
>
>
>
> 55593
>
> (HUNCHENTOOT:REAL-REMOTE-ADDR)
>
>
>
> "::1",
> ("::1")
>
> (HUNCHENTOOT:REQUEST-METHOD*)
>
>
>
> :GET
>
> (HUNCHENTOOT:SCRIPT-NAME*)
>
>
>
> "/info"
>
> (HUNCHENTOOT:QUERY-STRING*)
>
>
>
> "abc=123"
>
> (HUNCHENTOOT:GET-PARAMETERS*)
>
>
>
> (("abc" . "123"))
>
> (HUNCHENTOOT:HEADERS-IN*)
>
>
>
> ((:HOST . "localhost:8088")
>  (:USER-AGENT
>  . "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13)
> Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13")
>  (:ACCEPT .
> "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
>  (:ACCEPT-LANGUAGE . "en-us,en;q=0.5") (:ACCEPT-ENCODING . "gzip,deflate")
>  (:ACCEPT-CHARSET . "ISO-8859-1,utf-8;q=0.7,*;q=0.7")
>  (:COOKIE . "hunchentoot-session=1%3A6B0FCEA500DFA94C56F6273D56006E9D")
>  (:AUTHORIZATION . "Basic bG91OjEyM2E=") (:X-FORWARDED-FOR . "::1")
>  (:X-FORWARDED-HOST . "localhost") (:X-FORWARDED-SERVER . "::1")
>  (:CONNECTION . "Keep-Alive"))
>
> (HUNCHENTOOT:COOKIES-IN*)
>
>
>
> (("hunchentoot-session" . "1:6B0FCEA500DFA94C56F6273D56006E9D"))
>
> (HUNCHENTOOT:USER-AGENT)
>
>
>
> "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206
> Ubuntu/10.10 (maverick) Firefox/3.6.13"
>
> (HUNCHENTOOT:REFERER)
>
>
>
> NIL
>
> (HUNCHENTOOT:REQUEST-URI*)
>
>
>
> "/info?abc=123"
>
> (HUNCHENTOOT:SERVER-PROTOCOL*)
>
>
>
> :HTTP/1.1
>
> On Tue, Mar 29, 2011 at 4:19 AM, Jim Barrows <jim.barrows at gmail.com>
> 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.
> > --
> > James A Barrows
> >
> >
> > _______________________________________________
> > tbnl-devel site list
> > tbnl-devel at common-lisp.net
> > http://common-lisp.net/mailman/listinfo/tbnl-devel
> >
>
> _______________________________________________
> tbnl-devel site list
> tbnl-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/tbnl-devel
>



-- 
James A Barrows
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/tbnl-devel/attachments/20110329/52786053/attachment.html>


More information about the Tbnl-devel mailing list