On Monday, November 7, 2016 at 11:15:59 PM UTC-8, Luke wrote:
> I'm sure I've missed something incredibly simple here, but I can't seem to 
> get a POST handler to work at all.
> 
> ```scheme
> #lang racket                                                                  
>                                                                               
>                                            
> 
> (require web-server/http
>          web-server/servlet
>          web-server/servlet-env)
> 
> ;; Sign in GET handler
> (define (sign-in-get req)
>   (response/xexpr
>     `(html (head (title "GET"))
>            (h1 "GET HANDLED"))))
>            
> ;; Sign in POST handler
> (define (sign-in-post req)
>   (response/xexpr
>     `(html (head (title "POST"))
>            (h1 "POST HANDLED"))))
> 
> (define (start req)
>   (dispatch req))
> 
> (define-values (dispatch url)
>   (dispatch-rules
>     [("sign-in" "post") sign-in-post] ;; <-- This handler does not seem to 
> get bound
>     [("sign-in") sign-in-get])) ;; <-- This handler does work at /sign-in
> 
> (serve/servlet start
>                #:servlet-path ""
>                #:port 8080
>                #:stateless? #t
>                #:servlet-regexp #rx"")
> ```
> 
> This is a simplification of a more complex route configuration.
> 
> I've been spending time here:
> http://docs.racket-lang.org/web-server-internal/
> 
> and here:
> https://docs.racket-lang.org/web-server/
> 
> and here:
> https://docs.racket-lang.org/web-server/dispatch.html
> 
> and most importantly, here:
> https://docs.racket-lang.org/web-server/dispatch.html#%28form._%28%28lib._web-server%2Fdispatch..rkt%29._dispatch-rules%29%29
> 
> If I'm reading the docs at that last link correctly (which I so clearly am 
> not :-)), it looks like the suspect line should be more like:
> 
> ```scheme
> [("sign-in") (#:method "post") sign-in-post]
> ```
> 
> But that throws an `unexpected term` error for the `dispatch-rules` call.
> 
> With the above configuration, I can load the form at /sign-in, but when I 
> click, I get the Racket webserver 404 message.
> 
> As I said, I'm sure this is something incredibly simple, so please forgive my 
> scheme & racket noobness, any help would be appreciated!
> 
> 
> Thanks,
> 
> Luke

Gotta love that code formatting. :-/

Sorry for making a mess in here.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to