summaryrefslogtreecommitdiff
path: root/dynamic/capabilities/rsvp.scm
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.org>2022-05-08 15:51:15 -0400
committerJakob L. Kreuze <zerodaysfordays@sdf.org>2022-05-08 19:10:20 -0400
commit3fdede71c41393a948cf05d7b028e1f2b449a895 (patch)
treea79b93994fa88897d945e98b190228c6729bc1b3 /dynamic/capabilities/rsvp.scm
parent95eb12188e85af6788ea3ec265043680bd625bd3 (diff)
[scheme] middleware-ish way of specifying headers
Diffstat (limited to 'dynamic/capabilities/rsvp.scm')
-rw-r--r--dynamic/capabilities/rsvp.scm21
1 files changed, 9 insertions, 12 deletions
diff --git a/dynamic/capabilities/rsvp.scm b/dynamic/capabilities/rsvp.scm
index 527f7a1..4ac2eff 100644
--- a/dynamic/capabilities/rsvp.scm
+++ b/dynamic/capabilities/rsvp.scm
@@ -102,12 +102,12 @@ It is a base64 string, encoding `%vanity-length' bytes of randomness."
"Handler for RSVP'ing to an event."
(let ((params (params->rsvp-create params)))
(cond ((not params)
- (values (build-response #:code 400 #:headers '((Access-Control-Allow-Origin . "*")))
+ (values (build-response #:code 400)
(scm->json-string
`((success . #f)
(error . "Invalid form data")))))
((not (valid-invite-code (rsvp-create-code params)))
- (values (build-response #:code 400 #:headers '((Access-Control-Allow-Origin . "*")))
+ (values (build-response #:code 400)
(scm->json-string
`((success . #f)
(error . "Invalid invitation code")))))
@@ -123,8 +123,7 @@ It is a base64 string, encoding `%vanity-length' bytes of randomness."
(rsvp-create-email params)
(rsvp-create-attending params)
(rsvp-create-guests params)))
- (values '((content-type . (application/json))
- (Access-Control-Allow-Origin . "*"))
+ (values '((content-type . (application/json)))
(scm->json-string
`((receipt . ,receipt-code)))))))))
@@ -160,12 +159,12 @@ It is a base64 string, encoding `%vanity-length' bytes of randomness."
"Handler for updating an RSVP to an event."
(let ((params (params->rsvp-update params)))
(cond ((not params)
- (values (build-response #:code 400 #:headers '((Access-Control-Allow-Origin . "*")))
+ (values (build-response #:code 400)
(scm->json-string
`((success . #f)
(error . "Invalid form data")))))
((not (valid-receipt-code (rsvp-update-code params)))
- (values (build-response #:code 400 #:headers '((Access-Control-Allow-Origin . "*")))
+ (values (build-response #:code 400)
(scm->json-string
`((success . #f)
(error . "Invalid receipt code")))))
@@ -189,7 +188,7 @@ It is a base64 string, encoding `%vanity-length' bytes of randomness."
(let* ((params (json-string->scm (utf8->string body))))
(cond ((assoc-ref params "id") (create-new-event-rsvp params))
((assoc-ref params "update") (update-event-rsvp params))
- (else (values (build-response #:code 400 #:headers '((Access-Control-Allow-Origin . "*")))
+ (else (values (build-response #:code 400)
(scm->json-string
`((success . #f)
(error . "Invalid invite/update code"))))))))
@@ -217,8 +216,7 @@ It is a base64 string, encoding `%vanity-length' bytes of randomness."
(rsvps (exec-query conn "SELECT fullname, email, attending, guests FROM rsvps WHERE event_id = $1" (list (car invitation)))))
(match (car event)
((i_ title description date location)
- (values '((content-type . (application/json))
- (Access-Control-Allow-Origin . "*"))
+ (values '((content-type . (application/json)))
(scm->json-string
`((title . ,title)
(description . ,description)
@@ -245,8 +243,7 @@ It is a base64 string, encoding `%vanity-length' bytes of randomness."
(rsvps (exec-query conn "SELECT fullname, email, attending, guests FROM rsvps WHERE event_id = $1" (list (car invitation)))))
(match (car event)
((i_ title description date location)
- (values '((content-type . (application/json))
- (Access-Control-Allow-Origin . "*"))
+ (values '((content-type . (application/json)))
(scm->json-string
`((title . ,title)
(description . ,description)
@@ -274,7 +271,7 @@ It is a base64 string, encoding `%vanity-length' bytes of randomness."
((and invitation-code (valid-invite-code (car invitation-code)))
(get-event-invitation (car invitation-code)))
(else
- (values (build-response #:code 400 #:headers '((Access-Control-Allow-Origin . "*")))
+ (values (build-response #:code 400)
(scm->json-string
`((success . #f)
(error . "Invalid invitation or receipt code"))))))))