Hi, At first I had the macro use `define`, but then I thought: "What if I want to conditionally define a route procedure?". My guess is, that then the define form would be inside some `cond` or `if` form and then it would not work (I did not check this assumption though, because my macro did not work yet.). That is why I looked for something that does what `module-define!` does.
On 7/21/19 3:26 AM, Mark H Weaver wrote: > Matt Wette <matt.we...@gmail.com> writes: > >> On 7/19/19 3:51 PM, zelphirkaltstahl wrote: >>> (module-define! (current-module) >>> ;; `route` should be `/container/json` for example. >>> route >> (quote route) > Yes, or equivalently: 'route > > As an aside, is there a reason to not define it more simply as follows? > > Mark > > --8<---------------cut here---------------start------------->8--- > (define-syntax define-api-route > (syntax-rules () > [(define-api-route route http-method my-content-type) > ;; `route` should be `/container/json` for example. > (define* (route docker-socket #:key (data #f)) > (call-with-values > (lambda () > ;; Here the route needs to be given as a string to `http-get`. > (http-get (variable-name->string route) > #:port docker-socket > #:version '(1 . 1) > #:keep-alive? #f > ;; Why is my quasiquote not working as expected? > #:headers `((host . ("localhost" . #f)) > (content-type . (,my-content-type (charset > . "utf-8")))) > #:body (scm->json-string data) > #:decode-body? #t > #:streaming? #f)) > (lambda (response response-text) > (let ([resp-text-as-string (bytevector->string response-text > "utf-8")]) > (cons response resp-text-as-string)))))])) > --8<---------------cut here---------------end--------------->8---