guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Write a macro which defines a procedure


From: Mark H Weaver
Subject: Re: Write a macro which defines a procedure
Date: Sat, 20 Jul 2019 21:26:48 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Matt Wette <address@hidden> 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---



reply via email to

[Prev in Thread] Current Thread [Next in Thread]