You want to use #:method in the dispatch-clause. From the docs, "If
method is left out, it assumed to apply to requests without methods
and GET methods." (i.e. not POST methods.)

http://docs.racket-lang.org/web-server/dispatch.html?q=dispatch-rules#%28form._%28%28lib._web-server%2Fdispatch..rkt%29._dispatch-rules%29%29

On Fri, May 12, 2017 at 9:19 AM, Rosso Wu <answer...@gmail.com> wrote:
> Hi everyone, recently i start learn write a  web api service in racket,but  
> in dispatch-rules part i had a problem.
>
>
> ; handler.rkt
>
> #lang racket
>
> (require
>     web-server/http)
>
> (define (user req)
>   (response/xexpr
>       #:mime-type #"application/json"
>       "{hello: User}"))
>
> ; routers.rkt
> #lang racket
>
> (require
>     web-server/dispatch
>
>     "handlers/handler.rkt"
>
> (provide api-dispatch)
>
> (define-values (api-dispatch api-url)
>     (dispatch-rules
>      [("user") user]
>      [else not-found]
>      ))
>
>
> when the app start, i use post method request 127.0.0.1:8000/user, but i got 
> 404 condition, how to make user function accept post method??
>
>
> thank you.
>
> --
> 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 racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
-=[     Jay McCarthy               http://jeapostrophe.github.io    ]=-
-=[ Associate Professor        PLT @ CS @ UMass Lowell     ]=-
-=[ Moses 1:33: And worlds without number have I created; ]=-

-- 
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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to