working lisp server implementation

This commit is contained in:
Chris Cochrun 2024-04-24 15:19:56 -05:00
parent 22e5161b4c
commit 1993554db0
6 changed files with 24 additions and 68 deletions

View file

@ -382,24 +382,29 @@ with the image attached"
(:td (cdr row))))))))))))
(hunchentoot:define-easy-handler (respond :uri "/camp-api") ()
(uiop:println "hey")
(setf (hunchentoot:content-type*) "plain/text")
(let* ((request-type (hunchentoot:request-method hunchentoot:*request*))
(data (hunchentoot:post-parameters* hunchentoot:*request*)))
(uiop:println (assoc "registration" data :test 'string=))
(uiop:println (tbnl:headers-out*))
(if (string= (cdr (assoc "registration" data :test 'string=)) "now")
(progn (uiop:println "did it")
(setf (hunchentoot:header-out "HX-Redirect") "https://secure.myvanco.com/L-Z772/campaign/C-13JPJ")
(uiop:println (tbnl:headers-out*))
(uiop:println (hunchentoot:return-code*))
(with-html-string
(:div
(:p "Payment"))))
(data (hunchentoot:post-parameters* hunchentoot:*request*))
(registration (cdr (assoc "registration" data :test 'string=)))
(health (cdr (assoc "health" data :test 'string=))))
(uiop:println data)
;; This is extremely necessary so that cors is right
(setf (tbnl:header-out :access-control-expose-headers) "*")
(if (string= health "later")
(progn (uiop:println "Selected health later")
(cond ((string= registration "now")
(setf (hunchentoot:header-out :HX-Redirect) "https://secure.myvanco.com/L-Z772/campaign/C-13JPJ")
(uiop:println (tbnl:headers-out*))
(uiop:println (hunchentoot:return-code*))
(mail-camp-form data nil))
((string= registration "full")
(setf (tbnl:header-out :HX-Redirect) "https://secure.myvanco.com/L-Z772/campaign/C-13JQE")
(uiop:println (tbnl:headers-out*))
(mail-camp-form data nil))))
(progn
(with-html-string
(:div
(:p "Thank You")))))))
(uiop:println "Health now")
(setf (tbnl:header-out :HX-Redirect) (format nil "/camp-health-form?registration=~A" registration))
(uiop:println (tbnl:headers-out*))
(mail-camp-form data nil)))))
(defun define-post-form-handler (uri mail-function)
"Take a uri and a mailer function and define a handler in hunchentoot