You could use (splicing) syntax class to help with normalization:
#lang racket
(require syntax/parse/define
(for-syntax syntax/parse
racket/syntax))
(begin-for-syntax
(define-splicing-syntax-class methods-cls
#:attributes (methods)
(pattern (~seq #:methods (method:expr ...))
#:with methods #'(list 'method ...))
(pattern (~seq #:method method:expr)
#:with methods #'(list 'method)))
(define-syntax-class route-cls
(pattern (route:string
handler:id
(~alt (~optional ms:methods-cls
#:name "#:method, or #:methods option")
(~optional (~seq #:when guard-e:expr)
#:name "#:when option")) ...)
#:with methods #`#,(or (attribute ms.methods) #'(list))
#:with guard #`#,(attribute guard-e))))
(define-simple-macro (routes :route-cls ...)
#:with name (format-id this-syntax "axio-routes")
(define name (list (list route handler methods guard) ...)))
(define (foo-handler) 0)
(define (bar-handler) 0)
(define (baz-handler) 0)
(define (use-bar-handler?) 0)
(routes
("/foo" foo-handler #:method put)
("/bar" bar-handler #:methods (put update) #:when use-bar-handler?)
("/baz" baz-handler))
axio-routes
--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/ffc7ec25-f663-4d1d-a3d6-d3097d9c3963%40googlegroups.com.