From 4d829b832212fd73578ccfa092261616c17268a4 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Tue, 29 May 2012 13:24:26 -0600 Subject: [PATCH] Fixes PR12799, but it would be cool to support syntax/parse directly --- .../web-server/scribblings/dispatch.scrbl | 79 +++++++------------ 1 file changed, 28 insertions(+), 51 deletions(-) diff --git a/collects/web-server/scribblings/dispatch.scrbl b/collects/web-server/scribblings/dispatch.scrbl index 18c8d16937..149c867564 100644 --- a/collects/web-server/scribblings/dispatch.scrbl +++ b/collects/web-server/scribblings/dispatch.scrbl @@ -104,21 +104,26 @@ or else the filesystem server will never see the requests. @section{API Reference} -@defform*[#:literals (else ~optional ~seq syntax or) - [(dispatch-rules - [dispatch-pattern - (~optional (~seq #:method method) #:defaults ([method #'(or #f "get")])) - dispatch-fun] - ... - [else else-fun]) - (dispatch-rules - [dispatch-pattern - (~optional (~seq #:method method) #:defaults ([method #'(or #f "get")])) - dispatch-fun] - ...)] - #:contracts - ([else-fun (request? . -> . any)] - [dispatch-fun (request? any/c ... . -> . any)])]{ +@defform/subs[#:literals (else) + (dispatch-rules + dispatch-clause ... + maybe-else-clause) +([dispatch-clause + [dispatch-pattern maybe-method dispatch-fun]] + [dispatch-pattern + () + (string . dispatch-pattern) + (bidi-match-expander ... . dispatch-pattern) + (bidi-match-expander . dispatch-pattern)] + [maybe-method + code:blank + (code:line #:method method)] + [maybe-else-clause + code:blank + [else else-fun]]) +#:contracts +([else-fun (request? . -> . any)] + [dispatch-fun (request? any/c ... . -> . any)])]{ Returns two values: the first is a dispatching function with the contract @racket[(request? . -> . any)] that calls the appropriate @@ -136,47 +141,19 @@ dispatcher does not apply. without methods and GET methods. } - -@racketgrammar[dispatch-pattern - () - (string . dispatch-pattern) - (bidi-match-expander ... . dispatch-pattern) - (bidi-match-expander . dispatch-pattern)] -@defform*[#:literals (else ~optional ~seq syntax or) - [(dispatch-rules+applies - [dispatch-pattern - (~optional (~seq #:method method) #:defaults ([method #'(or #f "get")])) - dispatch-fun] - ... - [else else-fun]) - (dispatch-rules+applies - [dispatch-pattern - (~optional (~seq #:method method) #:defaults ([method #'(or #f "get")])) - dispatch-fun] - ...)] - #:contracts - ([else-fun (request? . -> . any)] - [dispatch-fun (request? any/c ... . -> . any)])]{ +@defform[ + (dispatch-rules+applies + dispatch-clause ... + maybe-else-clause)]{ Like @racket[dispatch-rules], except returns a third value with the contract @racket[(request? . -> . boolean?)] that returns @racket[#t] if the dispatching rules apply to the request and @racket[#f] otherwise. } -@defform*[#:literals (else ~optional ~seq syntax or) - [(dispatch-case - [dispatch-pattern - (~optional (~seq #:method method) #:defaults ([method #'(or #f "get")])) - dispatch-fun] - ... - [else else-fun]) - (dispatch-case - [dispatch-pattern - (~optional (~seq #:method method) #:defaults ([method #'(or #f "get")])) - dispatch-fun] - ...)] - #:contracts - ([else-fun (request? . -> . any)] - [dispatch-fun (request? any/c ... . -> . any)])]{ +@defform[ + (dispatch-case + dispatch-clause ... + maybe-else-clause)]{ Returns a dispatching function as described by @racket[dispatch-rules]. }