(defmacro make-json-request (url method json-var-name template func) (check-type url string) (check-type method http-method) (check-type json-var-name symbol) (alexandria:with-gensyms (params-var-name) `(setf (ningle:route *app* ,url :method ,method) (lambda (,params-var-name) (with-bucket (lambda () (when-json-request (setf (getf (lack.response:response-headers ningle:*response*) :content-type) "application/json") (funcall (lambda (,params-var-name) (let ((,json-var-name (first (lack.request:request-parameters ningle:*request*)))) ;; (push ,json-var-name *test*) (if (validate-json ,json-var-name ,template) (handler-case (funcall ,func ,params-var-name) (entry-not-found () ;;this catches a condition that is called when a constituency is ;;invalid. ,(get-response :404 t))) ,(get-response :400 t)))) ,params-var-name))))))))