[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What is needed in guildhall to include it in Guile?
From: |
Amirouche |
Subject: |
Re: What is needed in guildhall to include it in Guile? |
Date: |
Wed, 1 Mar 2017 21:34:57 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 |
Le 01/03/2017 à 20:35, Amirouche a écrit :
Le 23/02/2016 à 17:57, Arne Babenhauserheide a écrit :
That said I have an issue with registration/login
stuff anything related with setting cookies I don't find a good
abstraction,
for it.
I keep you posted.
So I found a solution that satisfy me. Here is it:
(define (pair->set-cookie item)
`(Set-Cookie . ,(string-append (symbol->string (car item))
"="
(cadr item))))
(define (sxml->set-cookies sxml)
(match sxml
((('doctype doctype)
('html ('@ . options) . rest))
(map pair->set-cookie options))
(_ '())))
(define (sxml->response sxml)
(let ((set-cookies (sxml->set-cookies sxml)))
(values `((content-type . (text/html)) ,@set-cookies)
(lambda (port)
(sxml->html sxml port)))))
;;; handler
(define (handler request body)
(sxml->response `((doctype "html")
(html
(body "echo")))))
(format #t "Héllo! Go to http://localhost:8080\n")
(run-server handler))
amz3